BuddyDev

BuddyPress Activity Shortcode: Embed BuddyPress Activities anywhere

Do you want to embed your BuddyPress activities in posts or pages? If yes, Here is a tutorial that will help you.

Recently, I was working on one of our upcoming BuddyPress themes(Hi Buddy Theme) and I wanted to allow site administrators the option to embed activities in pages/posts. So, I wrote a simple shortcode to just do that.

The shortcode will allow you to pass any options that is acceptable by the 'bp_has_activities' function.

The simple strategy I used was to include the activity loop and make a custom call to 'bp_has_activities' to modify the generated activities.

Here is the class that I wrote

Here is the way you can specify options

[activity-stream option_name=option_val option_name2=option_val2  and so on]

The accepted parameters:-

  • title(string) :- what should be the title of the activities section
  • pagination(int):- 0 or 1(do you want to hide or show the activity pagination at the bottom of the list)
  • display_comments(sting, int):- possible values are threaded|stream|0(use 0 to hide activity comments)
  • include(int|string):- individual activity id or comma separated list of activities, useful in case you want to list specific activities
  • exclude(int|string):-individual activity id or comma separated list of activities, useful in case you want to exclude specific activities from the list
  • sort(string):- ASC|DESC (how to sort the activities in ascending or descending order)
  • page (int):- which page to load, e.g 1st page or 10th page of activity
  • per_page(int):- How many activities per page(default is 5)
  • max(int):- Limit the maximum no. of activities to be included in the list
  • scope(string):- pre-built activity filters for a user (possible values are friends/groups/favorites/mentions)
  • user_id(int):- If you want to list a particular user's activity
  • object(string):- object to filter on e.g. groups, profile, status, friends(what type of activity is this)
  • action(string):- action to filter on e.g. activity_update, new_forum_post, profile_updated(why this activity was created)
  • primary_id(int):- object ID to filter on e.g. a group_id or forum_id or blog_id etc. We will see the use in a minute.
  • secondary_id(int):- secondary object ID to filter on e.g. a post_id(I don't think you are going to use it)
  • search_terms(String):- In case you want to list the results of activity search

We will see some examples in a minute. Before that, I will just like to clarify that you can use the combination of above options to list any type of activity you want.

Examples:-

List all activities of user with user_id=1

[activity-stream user_id=1]

List 10 recent activities per page:-

[activity-stream per_page=10]

List activities containing word "awesome"

[activity-stream search_terms='awesome']

List all group activities:-

[activity-stream object=groups]

List all activities of  the group Batman Fan club(Assuming that the group id is 2)

[activity-stream object=groups primary_id=2]

Well guys, It's up to you to explore the possibilities.

In case you want it as a plugin, we have got you covered:)

Download Link:-

https://buddydev.com/plugins/bp-activity-shortcode/

Do you think the activity embedding in posts using shortcode is useful? Please do let me know your suggestions/feedback for the enhancements or anything you want. I will love to hear from you.

99 Responses to BuddyPress Activity Shortcode: Embed BuddyPress Activities anywhere

  • Very nice! Many thanks 🙂

  • I installed the plugin, when I use the shortcode on the homepage, it just says viewing 1 of 10 items, but it doesn't display any of the items, see example here: http://www.bmoresalsa.com/.

    There is plenty of activity in the steam when I use a widget, but the shortcode I must be using wrong. I used this variation of the shortcode, [activity-stream per_page=10]

    Any advice?

    • Hi Salsa,
      This plugin does depend on theme. Can you please check your theme and see if activity/entry.php is present there?

  • Great Plugin!
    Is it possible make the same shortcode for "What's New?" form?

  • This is awesome, but is it me, or does this only work with the buddypress theme, and not with others?

    • Hi Skytechh,
      Thank you.
      It does depend on a theme file. Can you please check if your theme has activity/entry.php? I thought including the entry.php from theme will make it more acceptable for theme authors. Btw, which version of WordPress/BuddyPress you are using? I tested with BP 1.7.2+WP 3.5.1

    • @bphelp
      I use BuddyPress Activity Plus plugin. How to add buttons on this plug-in this form. Should be like this: http://s.w.org/plugins/buddypress-activity-plus/screenshot-1.png?r=837849

  • I installed both your shortcode plugin and the activity-widget. The latter performs OK but the shortcode only renders "Latest Activity" followed by a sentence with the (correct) number of activities without showing the activities themselves. Any ideas?

    • Hi Peter,
      As I see in all the comments, there seems to be same issue. Are you using a BuddyPress specific theme or is there anything specific about your installation. I just need to find out the issue. I have tested with BP default theme on BuddyPress 1.7.2 and it works. can you please provide more details?

      • Hi Brajesh,

        First of al: thanks for the quick response.
        My setup includes WordPress 3.5.1, Buddypress 1.7.2 and the Twentywelve theme. And no, I cannot find an entry.php anywhere, let alone in an activity folder.

        • Hi Peter,
          Thank you for the prompt and detailed reply. I am going to test it with the BP fallback which applies to twenty 10 and will post quickly.

          Thanks
          Brajesh

        • Hi Peter,
          There was a problem with templates using the compact mode. I have fixed it in 1.0.1. Please upgrade to 1.0.1 and It will work.
          Please do let me know if it works for you or not?

      • I just copied entry.php from the Buddypress theme to a new Activity subfolder in my theme. That made it work!

        • Wow, 1.0.1 works flawless. Thanks!
          If this required patience, I'm extremely curious as to what you can do when in a rush 😉

          Ever thought about a shortcode for the BP What's new form?

        • HI Peter,
          Thank you.
          Sure, I have heard about it now 🙂 Hoping to put something in next couple of days 🙂

  • Hi All,
    Just wanted to inform that version 1.0 only worked with Themes supporting BuddyPress explicitly(which included BuddyPress template files).

    I have updated the plugin to version 1.0.1 and It will work with any theme now.

    Thank you all for reporting the issue and having patience with me.

    Thanks
    Brajesh

  • Hi,

    First want to say thanks for creating this great plugin. Second, I was wondering if you could help me figure out an styling issue I'm experiencing with it.

    Using the shortcode on my front page (currently the site is private) is rendering correctly, accept for some of the basic styling features; the Comment and Favorite buttons are only links, and don't have the styled buttons, and, each post and comment displays as a bulleted list (square bullets display left of author's names). Horizontal rulers separating posts are also missing.

    I'm running WordPress Twenty Ten 3.6, and BuddyPress 1.8.1.

    Would really appreciate your guidance!

    Thank you so much in advance.

    Daniel

    • Hi Daniel,
      I am sorry I could not help much.
      I hope you have found a solution. If you are still looking for the help, please do let me know. I will be happy to help.

      Thanks
      Brajesh

      • Hi Brajesh,

        Thank you for your response! I believe your plugin could be very useful on my site and would love to have your help with the issues I've been facing (listed in my first comment above).

        To summarize, it appears that styling is not rendering when using the shortcode.

        The most recent WordPress and plugin versions are installed, although, I noticed that a CSS file was not included in the plugin file when I installed it.

        Perhaps this is the cause?

        Cheers,
        Daniel

  • Using this plugin but there are no styles….what is setup wrong?

    http://www.murfreesboro.com/home-page/

    • Hi Stephan,
      Apologies for the delayed reply. I just checked your site. You are using a theme that makes buddypress use theme compat. The css included with theme compat only works when things are wrapped under a div with id buddypress. I will update this plugin to have that as an option tomorrow.

      Thanks
      Brajesh

  • Brajesh,

    Have you thought about "ajax-ifying" the calls so that the page doesn't change when the next page of activity is requested?

    I'm using your shortcode in a Tab component but every time I click to go to the next page, the entire page refreshes and tab I was on is no longer selected.

    Leromt

    • Hi Lermont,
      Thank you for asking. That is certainly a very good idea. Will look at it an implement it in next release for BP 1.9 (coming in next few days).

  • Any update on, “ajax-ifying” the calls? 🙂

    • Hi Samuel,
      I haven't been able to do that. Will do that in a week when BuddyPress 2.0 comes out.

  • I'm using mhthemes, it just stated latest activity and then nothing else appear. is it a theme compability problem?

    • Hi Hadi,
      Are you using plugin? If yes, Please make sure you are using version 1.0.2. It will work with any theme.

  • Hello,

    How do I get the activity + input box onto a dedicated homepage… I don't just want the activity page… but a custom page with the activity stream and other stuff.

    L.

    • Hi Lance,
      Apologies for the delayedreply.
      Currently It does not support that. I may be looking at it in around 3-4 weeks and see if I can get it working.

      Thanks
      Brajesh

  • Hello, I'm looking for a plugin that will allow me to embed the group activity on a page/ post- but not just to show the activity , also to be able to comment and do whatever the group allows within the new page. Much like what the embedded bbpress forum shortcodes allow you to do.
    Does this plugin do that?
    Thank you.

    • Hi Milena,
      this plugin does allows you to embed group activity and allow commenting on that but won't allow adding new group activity on the page.

      • Hi, thank you for answering. So you can comment and like a post but not add a new one?

        It seems a small step towards a fully capable shortcode. I am looking for the same soulution as the previous commenter. Hope to hear from you!

  • Hi Brajesh!

    Any news on adding the input box to the shortcode?

  • Hello,

    Continue to find great plugins here on your site. Thanks for all your work. I am testing this one to see if I can get it to work as I need.

    In a recent update, you said: "Also, do not show the activity listing on site activity, user activity and group activity when user is logged in to the site."

    Is this a must? Here is why I ask, based on what I am testing:

    I added the shortcode into a text widget, which I then placed in a widgetized area just above the full Activity Stream. I did this to pull the most recent two posts from a specific user to have them be like 'sticky' posts.

    All site users must be logged in to access any BP pages, including the Activity page.

    So, because of this setup, no embedded activity displays.

    Is it possible that I 'deactivate' or modify this part of the code?

    Thank you.

    • I thought I would just mess with it and see what I could figure out… figured I couldn't break it too badly. 🙂

      Compared the (original) code above with what was in ftp. I commented out lines 81- 83, and that seemed to allow the display of the stream.

      If I should do something different, please let me know.

      I'm back to testing. As I wrap all this up, I'll be back to support your work by purchasing some of these that I can get to work for our needs.

      Thanks again

  • Is there anyway I could only show activity based of xprofile fields?

    For example, if someone enters ’Canada’ as their location on xprofile fields, can I filter the activity stream so that it only shows activity from people in ’Canada’?

    I appreciate your time very much and it would be extremely helpful if you could answer this.

    • Hi Brayden,
      I am sorry for the delayed reply.

      That is possible, but a little bit of code will be required. There are two ways.

      Strategy 1:-
      1. get current user's location
      2. Based on that find all users with that location
      3. filter on 'bp_activity_get_where_conditions' and add the sql condition for where user_id IN { list of our filtered user ids}
      That will do it.

      Strategy 2:-
      1. When a new activity update is made, store the location id(or name) in the activity meta
      2. filter on bp_after_has_activities_parse_args or bp_before_has_activities_parse_args and pass these parameter as meta query. That will work too.

      If I had to choose one, I will prefer first strategy as that will be more efficient.

      Hope that helps.

  • How do I apply for group id on the default activity posting form?

    • Hi Robi,
      Do you mean the post form should only allow posting to a perticular group. I am sorry but this plugin does not restricts that. It uses the activity/post-form.php from your theme(if present) or from bp-legacy. It is not difficult to achive what you are looking for but you will need to modify the activity/post-form.php. Check whats-new-post-object and whats-new-post-in in that file and you will get the idea.

      Hope that helps.

      • Thank you much advice.

  • Brajesh

    I tried using the shortcode with the divi theme.

    I am trying to accomplish a 3 column webpage with the activity stream in the middle and the sidebar on the right of the page I can do without the left side Juicer widget that is shown

    I have a screenshot I can send you to what I am looking at or just go to my development page http://devwp.ttpgolf.com/test-activity/

    Please let me know what I can do I can resize all column within the divi theme

    • Hi Dough,
      Can you please explain the issue. I am sorry but I see that the shortcode is not generating any content there. Just plain shortcode is visible. Is that the problem? or is there something else?

      • Hi Brajesh,
        so
        Yes that is the issue the plain shortcake is showing I am using the code as seen above [activity-stream]so the shortcode is not generating any content.

        Please advise

        • Hi Dough,
          As I see there, The shortcode is being quoted there like 'activity-stream'. Is it done by you or the theme?

          If you have quoted it, please remove the quote. Shortcode names should not be quoted.

      • I have taken off the quotes but the same issue persists. Has anyone ever tried it on the divi theme from elegant themes? It is a popular theme.

        This will help me out tremendously. I used the divid builder and used the "Code" Box to input the shortcake

        • *shortcode

        • Hi Dough,
          I am sorry in that case. It is a theme specific issue then. Please ask Elegant theme support and they will be able to help you with this. I haven't used divi, so may not be able to assist with this.

  • Hello. I read on a post from 2013 that someone posted code to add to your shortcake plug-in to create a 'What's new' comment box so people can post right form your short code feed, but it did not work. Have you found any updated ways for this to work?

    Theses the code I am referring to.. Thank you

    https://buddydev.com/snippets/719-add-post-form/

    • Hi James,
      In our last update, we have included that feature as experimental. Please take a look at the plugin page and you will see the option 'allow_posting' that controls whether to show the form or not.
      Hope that helps.

      • Hello Bajesh,

        Thank you for your timely response. We got it to work just as you responded, so that part is working. =)

        The issues we are having now is that on our latest activity feed that we inserted on a particular page, at the bottom of the list says (Viewing 1 – 0 of 0 items) even though it is showing the latest 10 activities. It also does not give the option to scroll to other pages of activity, which I believe it is supposed to.

        We suspect it ay be our theme template that may be disallowing this, but perhaps you have another idea? Any advice would be greatly appreciated.

        James

        • Anyone out there have an idea what could be going on? PLEASE HELP~!

        • Hi James,
          I am sorry I missed your comment. Please upgrade again. It is fixed now. if you are using BuddyDev dashboard, you should have got a notification for upgrade and can seamlessly upgrade from your plugins page. It was a bug in the plugin and I got it fixed last week.
          Please do check and let me know.

          Thank you
          Brajesh

        • The update fixed it great! Thanks!

  • Ben #

    Hi, Really great plugin! I spent hours trying to find out how to edit activity stream for custom display, and failed miserably. I am trying to implement the post editing function you list on documentation and it seems to work, but the ability to @user is not. Is this a known limitation or am I possibly doing something wrong?

    Ben

    • Hi Ben,
      Thank you for the comment. I am glad it helped. I haven't tested the @ mention posting. Still, I don't see any reason why it will not work. Will be testing today and get back to you.

      Thank you
      Brajesh

      • Ben #

        Hi, Brajesh,

        Thanks for you quick reply! not to pile on here, but I did notice the where to post div height and margin are slightly off, so the drop down selector fails (that is, it closes drop down of post to options list) when user tries to select this. I'm not sure if this would be a related issue (sorry, I'm relatively new to development), but I adjusted CSS and the drop down stays open now, though @ still isn't working.

  • Hey Brajesh,

    I have another question. Is it possible to set the feed to auto refresh using your plug-in? Thanks!

  • Hi,

    Great plugin!!! and it works as it should!
    One small question – is it possible to hide the users avatar? It shows the name so we dont need the avatar.
    I hope you can help me 🙂

    Best regards
    Tonny

    • Hi Tonny,
      Thank you for the comment. Please use css to hide avatars. Should be simple to do that.

  • Hello, thank you for the great plugin. How can display my custom post type and custom taxonomy created by me via this plugin? What short code do I need to use to display the activity of a particular taxonomy? Waiting for your reply

    • Hi Vijay,
      Thank you for the comment. This plugin does not have options to filter by post types. You can filter all posts(including custom posts) activity though using component='blogs'

  • does this show activities for 1 user or all users?

    • Hi Victor,
      It does allows. Please use user_id=Numeric_ID_OF_USER
      in the shortcode.

      Hope that helps.
      Regards
      Brajesh

  • Hello this is a great plugin for buddypress thank you, one question have you looked into ajaxifying pagination by any chance ? i cain't figure it out myself ! Thanks ahead

    • Hi Davd,
      Thank you for asking. The ajaxification is in the theme domain. It can be easily done. I may do that as an example next week with my upcoming plugin. I will link you once I have posted that.

  • Hi Brajesh, I am new all of this and you're plugin has saved me a lot of work. I've been trying to add the what's new box to the code but nothing happens. I added the this short code: [activity-stream allow_posting=1]
    Is that correct?
    Thanks in advance!

    • I found the problem but now only the default box appear. Is it possible to use the same container as BuddyPress Activity Plus uses?

      Thanks in advance!

      • Thank you. I am glad you found the solution.

        About Activity plus, The Activity Plus will only work with the default BuddyPress form that too on profile/groups/sitewide activity. Last time I checked, they did not work if the form was used somewhere else. I am sorry for the inconvenience.

  • Hello! Great plugin but I am having a big problem. Whenever I try to filter by object=groups it says that no activity was found. This is what I need the plug in for. Can you please tell me what the problem is? All the groups on my site are private, does this have anything to do with it?

    • HI Dario,
      Are you using other filter parameters too? I tested by using the following shortcode

      [activity-stream object=groups]

      and it is working fine for me.

      Thank you
      Brajesh

      • Hey there! I am using the exact same shortcode you posted:

        and it says "no activity was found please try another filter" I am using the BuddyBoss theme and all my groups are private but I am a member of all of them. Is there any more information I can provide you with? I'd love to start using this plug in.

        • Also, all of the parameters work except for anything that has to do with groups or forums, such as new_forum_post etc. but unfortunately groups and their forums are exactly what I need this for!

        • Hi Dario,
          If the updates are from private group, they won't be listed. BuddyPress does not allow listing of private group activities on any p[age(except the group/the user's own activity page).

          Even if the user is logged in, private activities are not listed on the activity directory page. Same applies to this shortcode. It is the way current BuddyPress activity works.

        • Thank you for the response! All of my private group updates appear in the site wide activity stream when "my groups" is selected. Do you mean that this only works when public groups are listed in friends activity or all activity?

          If this is the case, I notice you have another plug in called Facebook Like Activity Streams which merges group activity and all activity.

          If I purchase this plug in, will my private group updates that I am a member of appear in the site wide activity stream along with my friends updates? Thank you.

  • Hey buddy Thank you so much for this tutorial.I am very new wordpress. This one exactly take me to what I want.Million Thanks.

  • is it possible for this plugin/shortcode to show the activity from more users, or even better, from specific user roles?

  • I'm having Activity Shortcode issues with the new version of buddypres. The images are not displaying correctly. Will there be an update fix?

    • Hi Jason,
      We have an issue with the BP Nouveau template at the moment. We are hopful to release an update by Monday/Tuesday. I am not sure if the image issue is part of this conflict or not, but the plugin will be BP Nouveau and BuddyPress 3.0 compatible by then.

      Thank you.

  • Hello,
    I'm a volunteer for an NGO, not a pro web-dev.. so sorry in advance if my question is stupid 🙂
    I'm using your plugin to display activity updates within the "comment" section of the various posts and enabling users to directely post "updates" from this section (so using [activity-stream allow_posting=1 action=activity_update] in my child theme).
    Right now, it does show all the updates (which is normal). Now, what I would like is to filter the displayed updates, based on wether they were published from the post.
    Is this possible? It looks like I could filter using the secondary_id parameter.. But how do I set it in the first place?
    Thanks a lot for your help!

  • Hello,
    I'm a volunteer for a small NGO in education, forgive me in advance if my question is foolish.
    So far, I'm using your plugin to display activity updates below each blog posts. Users can also post updates from there. So, I'm using [activity-stream allow_posting=1 action=activity_update], in a child theme's function. It works well.
    What I'd like to do, is to filter the list of updates to the one that have been published from this very blog post. I thought I could use the secondary_id paramater, but I have no luck with that. Something I don't understand is how do you set secondary_id in the first place (I'd like it to be equal the blog post id..)
    Any idea on how to implement that? Thanks a lot in advance
    Best,

    • Hi Laurent,
      My apologies for the delayed reply.

      Since the plugin does not keep track from where the activity was posted, you won't be able to filter it. A solution will be to modify the update routine and keep track of the post/blog/.

      The filter using secondary_id is not working for you as the details for blog post is not saved in the activity(The association information is not there).

  • woocommerce review post in activity stream and this short code .

    How do you edit it?

    I think that other people want to know the information.

    • I am not sure what WooCommerce plugin you are using. It is very specific to the review plugin and there is no general answer. Also, it has nothing to do with the shortcode but it needs proper work for filtering in BuddyPress activity.

      I am sorry but we are unable to assist with it at the moment.

  • YITH WooCommerce Advanced Reviews Premium

    this prugin .

  • Hi

    Can plugin shows newest images?

    • Hi Julh,
      It can show the activities with images but that will depend on which plugin you are using? Please post in our forum and we will help you with appropriate shortcode.

  • Hi Please help i want to add the action(string):- action to filter on e.g. activity_update, new_forum_post, profile_updated(why this activity was created) on my page so that it can be a post

    • Hi,
      You can use action=activity_update,new_forum_post,profile_updated

      one or more action type separated by comma.
      Regards
      Brajesh

  • Hi Please assist because the allow posting short-code does not have a post submit button

    • Hi Brajesh further to this , when posting i want to user to select from a drop list the group in which they are posting to , at the moment the post is not confined to any group , can you please make this update i would really appreciate it.

  • Hi Brajesh further to this , when posting i want to user to select from a drop list the group in which they are posting to , at the moment the post is not confined to any group , can you please make this update i would really appreciate it.