BuddyDev

BuddyPress Activity As wire updated for BuddyPress 1.8, BuddyPress 1.9+

This tutorial is now updated for BuddyPress 2.0

This is a much needed update for BuddyPress activity as Wire tutorial. Thank you all for your patience. As I said earlier, we are focusing again on BuddyDev and paying attention to what you all say, and here I am putting this update on your demand.

The goal of this tutorial is:-

  •  To use BuddyPress activity mention feature to emulate User wall/wire
  • Without any change in the theme code( That’s right )

To make BuddyPress Activity feature emulate the user wall/wire, we will go in three steps as below:-

  • Step 1: Show the activity post form on other user’s profile
  • Step 2: Filter the text that says “What’s new {username}” to say “Write something to {displayed_user_name}”
  • Step 3: Remove BuddyPress function which handles the post update action and hook our custom function that allows us to save the activity posted from other user’s profile as mention.

Here we go 🙂

Step 1: Sow the activity post form on other user’s profile:-

Activity Post form example

In the code below, we are showing the activity post form on other user’s activity/mention tab

That will show the form as shown in the previous image.

Step 2: Filter the text that says “What’s new {username}” to say “Write something to {displayed_user_name}”

Changing what's new

In the code below, we are filtering using the gettext filter.

Step 3: Remove BuddyPress function which handles the post update action and hook our custom function that allows us to save the activity posted from other user’s profile as mention.

So, all we need to do is remove the default handler for the post form and use our own. Here is the code that checks and removes the default handler and adds our own.

As you see above, we will need to write our custom function ‘devb_aawire_post_update’ to handle the activity post action.

Here is the code for that function:-

Step 4: On BuddyPress 2.0+, we need to filter the activity action to say wall post

Now, if a user posts, the activity is like this

Wire post

If you read through the code, It should be self explanatory. Still, we are using $is_wire_post variable to track if the current post is made as wire post. If it is wire post, we filter the activity action to say User 1 posted on User2’s wall. You can put all the above code in bp-custom.php or your theme’s functions.php

And to disable the box that says post in, we will need following css

whats-new-post-in-box

The above css code hides the drop down option that shows where to post( My profile/Groups etc).

Here is a surprise gift for you if you made till here. The BuddyPress Activity as wire is available as a plugin now and you can just drop in the plugin and activate. No need for any theme modification, except one line of css.

Download & Installation:-

https://buddydev.com/plugins/bp-activity-as-wire/

We will need to make 1-2 small change when BuddyPress 2.0 comes out ( The above code will work fine but we can utilize the dynamic activity action generation in a much better way).

Ok, Now it is your turn to let me know if it is working for you or not and what enhancements should I make?

24 Responses to BuddyPress Activity As wire updated for BuddyPress 1.8, BuddyPress 1.9+

  • It’s working for me with a standard WP theme but not with the Salutation theme I’m using. Step 2 (Filter the text that says “What’s new {username}” to say “Write something to {displayed_user_name}”) isn’t working with that premium theme. The functionality itself is here, only the what’s new text isn’t changed.

    • Thank you Hans.’
      That means they are not using buddypress as text domain as I have used in the plugin. you can change this line

      if( $text == "What's new, %s?" && $domain == 'buddypress' && !bp_is_my_profile() && bp_is_user() ){
      

      to

      if( $text == "What's new, %s?" && !bp_is_my_profile() && bp_is_user() ){
      
      

      and that will work.
      I next version I will remove the text domain check too. I used it to avoid any collision with other plugins, but after a second thought, It seems the text is not that much generic.

      • This change did not the job with Salutation. I didn’t had the time to debug why, but Salutation is sometimes a real brain twister. 😉

  • @Brajesh

    I am not able to see the post in user activity. When I am posting it on his/her wall, Its refreshing the activity list. Gr8. That’s fine. But when I go somewhere else and return back. There is not post posted by me on their wall. It is on activity page but not on the user activity page. And even the devb_aawire_filter_action is not working. I am getting the activity header as default.

    • Hi Mehul,
      1. The posts will appear under the mentions tab of activity.
      2. Are you using BuddyPress 2.0, I have to put a fix for BP 2.0.

  • // Remove post in box from activity wire other user posting activity post form 
    function remove_activity_post_in_box() {
    	
    
    body.activity.bp-user #whats-new-post-in-box{ display:none;}
    
    
    }
    add_action ('bp_head', 'remove_activity_post_in_box');
    
    
  • @sbrajesh, i think you can use it directly in the plugin so no need to add anything in the style sheet by the user.

    Note : I dont know why the style opening and closing tag is not showing on the above code.

    thanks

    • Thank you Abbey,
      I have updated the code. I did not think about including it directly in the page but I believe, we can give it a shot 🙂

  • @sbrajesh,

    see the complete code below as the above is incomplete.

    http://pastebin.com/wiDwdBdr

    Regards

  • @sbrajesh,

    Please when should we be expecting update of this tutorial for buddypress 2.0.

    This has stopped working.

    Regards

    • Hi Abbey,
      Thank you for the comment. I have updated the tutorial as well as the plugin for BuddyPress 2.0 now 🙂
      Thank you
      Brajesh

  • @sbrajesh,

    Thanks very much thats why i like you. always on point. you are the best.

    I am current building a theme that i want to release to the community for free.

    So this tutorial is very important for me and I will be buying your updated facebook like activity stream plugin soon. i have the old one which i got when i was still a full member.

    thank you

    • Hi Abbey,
      Thank you for the kind words 🙂
      I am looking forward to your theme, please do let me know if I can be of any help. Thank you for the interest in Facebook Like activity stream( It is now compatible with BuddyPress followers plugin too ).
      Regards
      Brajesh

  • Brajesh, can you check this support forum post I created regarding a possible enhancement for Wire https://buddydev.com/support/forums/topic/segregate-wall-posts-from-the-main-activity-stream-in-bpaaw/

  • Great plugin! I was wondering if there was a way to only allow friends to post on wall? And also have @mentions still work?

  • This is nice. However, it made the “All Member Notices” show up at the very bottom of the page on or below the footer.

  • Does this work with the Kleo theme? I a new to wordpress. Do I have to put in an y coding myself or are you just explaining the coding it took to make this work?

  • Any plans on updating this nice sweet little plugin to current version of WP and Buddypress versions?

    Thanks
    Kind regards
    Joans.

    • Hi Joans,
      I haven’t seen any breaking changes in recent BuddyPress versions. Are you seeing any issue?

      Thank you
      Brajesh

  • Hello! sorry for my English. I’m doing my site caundo DIV and use this plugin footer columns are cluttering. No way to fix it?

    • I am sorry but I am not able to help. Most probably some conflict with the theme layout.

Subscribe