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' ) {?>
<a class="view-post" href="<?php bp_activity_thread_permalink() ?>">View Blog Post</a>
<?php }
if ( bp_get_activity_object_name() == 'blogs' && bp_get_activity_type() == 'new_blog_comment' ) {?>
<a class="view-post" href="<?php bp_activity_thread_permalink() ?>">View Blog Comment</a>
<?php }
if ( bp_get_activity_object_name() == 'activity' && bp_get_activity_type() == 'activity_update' ) {?>
<a class="view-post" href="<?php bp_activity_thread_permalink() ?>">View Activity Status</a>
<?php }
if ( bp_get_activity_object_name() == 'groups' && bp_get_activity_type() == 'new_forum_topic' ) {?>
<a class="view-thread" href="<?php bp_activity_thread_permalink() ?>">View Forum Thread</a>
<?php }
if ( bp_get_activity_object_name() == 'groups' && bp_get_activity_type() == 'new_forum_post' ) {?>
<a class="view-post" href="<?php bp_activity_thread_permalink() ?>">View Forum Reply</a>
<?php }
}
add_action('bp_activity_entry_meta', 'my_bp_activity_entry_meta');
You’ll now have some neat buttons which call your user to action! Here’s an example for a blog post entry:
Credits
[bc_member name="etiviti" size="80" fields="About me,Website,Twitter Name"]


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?
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.
Can anyone confirm that this works A-okay with BP 1.5?
Same question. Anyone
It works in BP 1.5! At least it does for me!
The code shows only links on my website, no buttons.
How do I add the buttons like in the screenshot?
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’ ) {?>
<a class="view-thread" href="”>View Forum Thread
<a class="view-post" href="”>View Forum Reply
<?php }
And then the buttons give 404
Hi Manish,
This problem seems to be related to BuddyPress itself. The functionality that is used to create the links is present in Core..
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;
}
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:
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…
Paperbee
Paperbee
[bc_member name="etiviti" size="80" fields="About me,Website,Twitter Name"] is showing up
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!
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!
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?
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’ ) {?>
<a class="button" href="”>View Topic
<a class="button" href="”>View Reply
<?php }
Thanks Allen! Would it be possible if you’d post your edit as a gist (gist.com) or snippi (http://snippi.com/). I can then update the post with your updated code