Adding some cool “Call to Action” buttons to stream entries

When something happens within your BuddyPress Community, you usually want others to respond to this activity. That’s the whole core concept of Social networking. By default BuddyPress adds a “Reply” and “Favorite” button to activity stream items, and while this is cool, for some entries you would like the user to go somewhere. This simple snippet will add a additional button which points them in the right direction.

Add the following code to your Child Themes Functions.php or add it to BP-Custom.php in your plugin folder

/* Add Cool Buttons to Activity Stream Items */
function my_bp_activity_entry_meta() {
        if ( bp_get_activity_object_name() == 'blogs' && bp_get_activity_type() == 'new_blog_post' ) {?>
                View Blog Post
        
                View Blog Comment
        
                View Activity Status
        
                View Forum Thread
        
            View Forum Reply
        
              

You’ll now have some neat buttons which call your user to action! Here’s an example for a blog post entry:
Screen shot 2011 05 17 at 7.45.30 PM 680x291 Adding some cool “Call to Action” buttons to stream entries

Credits

[bc_member name="etiviti" size="80" fields="About me,Website,Twitter Name"]

BuddyPress Hosting Guide Looking for quality BuddyPress hosting? We will guide you through all the available hosting options and help you find the best webhost for your next BuddyPress project!

Something about bowe

BuddyPress fanatic, WordPress Theme designer and MultiSite community builder. Proud co-founder of PressCrew. Loves to use awesome in every sentence. Often described as a Dutch Treehugging Hippie.

21 Responses to Adding some cool “Call to Action” buttons to stream entries

  1. Tyler May 29, 2011 at 3:24 pm #

    Say I wanted View Blog Post to be listed before Favorite. Is there a way to determine the order in which those buttons are displayed?

    Reply
  2. stwc May 31, 2011 at 11:16 pm #

    Nice. Added these to my site’s activity stream — every little thing that helps users understand where and how things fit together on a BP site is very useful indeed.

    Reply
  3. AllMad.org Ranting September 7, 2011 at 5:36 pm #

    Can anyone confirm that this works A-okay with BP 1.5?

    Reply
  4. Acouphene October 23, 2011 at 7:00 pm #

    Same question. Anyone

    Reply
  5. bowe October 26, 2011 at 12:05 pm #

    It works in BP 1.5! At least it does for me!

    Reply
  6. Manish January 9, 2012 at 7:17 am #

    The code shows only links on my website, no buttons.
    How do I add the buttons like in the screenshot?

    Reply
  7. Manish January 15, 2012 at 6:00 am #

    I added the css for buttons

    but there is another problem. This code seems to cut (truncate) the url if the url is very long

    if ( bp_get_activity_object_name() == ‘groups’ && bp_get_activity_type() == ‘new_forum_topic’ ) {?>
    Reply

  • Bowe February 2, 2012 at 9:52 am #

    Hi Manish,

    This problem seems to be related to BuddyPress itself. The functionality that is used to create the links is present in Core..

    Reply
  • Jay Collier April 3, 2012 at 2:27 pm #

    This worked great for me with 1.5.5 and 3.3.1.

    I copied the CSS from the other buttons and added this to styles.css in my child theme:

    .activity-meta a.view-post
    {
    background: #ededed;
    background: moz-linear-gradient(top, #ffffff 0%, #e0e0e0 100%);
    background: webkit-gradient(linear, left top, left bottom, color-stop(0%,#ffffff), color-stop(100%,#e0e0e0));
    background: -webkit-linear-gradient(top, #ffffff 0%,#e0e0e0 100%);
    background: -o-linear-gradient(top, #ffffff 0%,#e0e0e0 100%);
    background: -ms-linear-gradient(top, #ffffff 0%,#e0e0e0 100%);
    filter: progid:DXImageTransform.Microsoft.gradient( startColorstr=’#ffffff’, endColorstr=’#e0e0e0′,GradientType=0 );
    background: linear-gradient(top, #ffffff 0%,#e0e0e0 100%);
    border: 1px solid #bbb;
    webkit-border-radius: 3px;
    border-radius: 3px;
    color: #555;
    outline: none;
    text-decoration: none;
    }

    Reply
  • Jay Collier April 3, 2012 at 2:28 pm #

    This worked great for me with 1.5.5 and 3.3.1.

    I copied the CSS from the other buttons and added this to styles.css in my child theme:

    .activity-meta a.view-post
    {
    background: #ededed;
    background: moz-linear-gradient(top, #ffffff 0%, #e0e0e0 100%);
    background: webkit-gradient(linear, left top, left bottom, color-stop(0%,#ffffff), color-stop(100%,#e0e0e0));
    background: -webkit-linear-gradient(top, #ffffff 0%,#e0e0e0 100%);
    background: -o-linear-gradient(top, #ffffff 0%,#e0e0e0 100%);
    background: -ms-linear-gradient(top, #ffffff 0%,#e0e0e0 100%);
    filter: progid:DXImageTransform.Microsoft.gradient( startColorstr=’#ffffff’, endColorstr=’#e0e0e0′,GradientType=0 );
    background: linear-gradient(top, #ffffff 0%,#e0e0e0 100%);
    border: 1px solid #bbb;
    webkit-border-radius: 3px;
    border-radius: 3px;
    color: #555;
    outline: none;
    text-decoration: none;
    }

    Reply
  • O'Ryan McEntire April 6, 2012 at 10:53 pm #

    I wonder if one could use this to build a totally customized activity stream.

    I’ve been trying to simplify the stream that shows up on my users profiles so i can just add it to their main profile page as a mini widget.

    something like :

    posted in the forums
    5mins ago

    replied to a comment
    10mins ago

    liked a comment
    2 days ago

    hmm…

    Reply
  • Bichoupanycq April 18, 2012 at 7:45 am #

    Paperbee

    Reply
  • Jermaulcevala April 18, 2012 at 10:49 am #

    Paperbee

    Reply
  • Daniel Schulz-Jackson May 19, 2012 at 5:21 pm #

    [bc_member name="etiviti" size="80" fields="About me,Website,Twitter Name"] is showing up

    Reply
  • Magnus June 25, 2012 at 1:23 pm #

    Hi!

    Excellent trick, very useful for adding extra clarity to how the activity stream works, especially with blog posts and discussion forums. Now, if I would want to re-arrange the order of the activity stream buttons (as some other people also have asked above), I would have to modify the corresponding template file, right?

    Thanks and I’d love to see more tricks here! ;)

    Reply
  • Magnus June 28, 2012 at 9:04 pm #

    Hi again!

    The extra buttons are great. However, if I click on “View Activity Status” that button is still visible on the page that only shows the single activity status. How would I remove this since it seems odd to link to the current page there?

    Thanks!

    Reply
  • Allen February 14, 2013 at 3:52 pm #

    I have a problem here. I use bbpress 2 and the button doesn’t show when a new forum topic is created. I use sitewide forums not group forums.

    My guess is i need to change groups to something else in this:

    if ( bp_get_activity_object_name() == ‘groups’

    I tried ‘forums’ , ‘bp-forums’ … and several more but it doesn’t work?

    What’s the correct object name for sitewide forums?

    Reply
  • Allen February 14, 2013 at 4:32 pm #

    Found the solution. Here’s the working code for the latest version of buddypress and bbpress (sitewide):

    if ( bp_get_activity_object_name() == ‘bbpress’ && bp_get_activity_type() == ‘bbp_topic_create’ ) {?>
    Reply

  • Jay Colliery Collier July 15, 2013 at 5:16 pm #

    Appears to not be working with BP 1.6, which is too bad. This was great.

    Reply
  • Magnus November 25, 2013 at 6:12 pm #

    Thanks Allen! The above code works for new forum posts. For forum replies (using the standalone bbPress plugin) the activity_type should be bbp_reply_create I think.

    Reply
  • Leave a Reply