Here are the slides from my WordCamp Europe 2013 presentation, on the subject of using the BuddyPress activity component for neat purposes: http://hardg.com/presentations/wordcamp-europe-2013/bp-activity/
Tag Archives: activity
New BuddyPress plugin: BP Lotsa Feeds
I’ve been working on a project recently with Kevin Prentiss and the other fine folks at Red Rover. Kevin is a big believer in the power of feeds, and I’m a big believer in the power of BuddyPress’s activity component, and together we realized that BuddyPress’s RSS support for its rich activity content is a bit lacking.
This new plugin, BP Lotsa Feeds, is meant to address the issue. It activates RSS feeds for just about everything in BuddyPress, from an individual member’s sitewide comments, to new group memberships for specific groups, to individual forum topics.
Read more about the plugin on its home page, and follow its development on Github. Thanks to Red Rover for sponsoring a cool plugin.
New BuddyPress plugin: BP External Activity
On the CUNY Academic Commons we have a MediaWiki installation running parallel to our WordPress/BuddyPress installation. In the past I had hacked together an inelegant and constantly breaking solution for importing wiki edit notifications into the BP activity stream. I’ve just written a small plugin called BP External Activity which solves the problem by using the BP activity API and RSS.
The plugin can be used to pull items from any RSS feed and add them to your BP activity stream, with customizable text. It’s feature-light right now (and requires some hand-coding to work) but it’s still pretty much the coolest thing ever. I will update it to be better when I get around to it.
Adding an “email to members” checkbox to the BuddyPress group activity stream
During the recent upgrade from BuddyPress 1.1.x to BuddyPress 1.2.x, and the subsequent move away from group wires to interactive group activity streams, one thing that some users on the CUNY Academic Commons missed was the “Notify members by email” checkbox of the old wire.
This morning I wrote a bit of code to add that kind of functionality to group activity streams. There are three functions, each of which goes in your plugins/bp-custom.php file.
First, adding the checkbox to the activity box. Notice that it only shows up when you’re on a group page.
[code language=’php’]
function cac_email_activity_checkbox() {
if ( !bp_is_groups_component() )
return;
?>
Second, handling the data when it gets to the server and sending the emails. Obviously, you’ll want to change the text of the email to match your own site and your own preferences. The line “remove_action( ‘bp_activity_after_save’ , ‘ass_group_notification_activity’ , 50 );” is there to prevent an email notification from being sent if you’re using the Group Activity Notification plugin, a big official release of which is coming soon 🙂
[code language=’php’]
function cac_email_activity_handler( $activity ) {
global $bp;
if ( $_POST[‘mailme’] == ‘mailme’ ) {
$subject = sprintf(‘[CUNY Academic Commons] New update in the group “%s”‘, $bp->groups->current_group->name );
$message = strip_tags($activity->action);
$message .= ‘
‘;
$message .= strip_tags($activity->content);
$message .= ‘
——-
‘;
$message .= sprintf(‘You recieved this message because you are a member of the group “%s” on the CUNY Academic Commons. Visit the group: %s’, $bp->groups->current_group->name, $bp->root_domain . ‘/’ . $bp->groups->current_group->slug . ‘/’ . $bp->groups->current_group->slug . ‘/’ );
//print_r($message);
if ( bp_group_has_members( ‘exclude_admins_mods=0&per_page=10000’ ) ) {
global $members_template;
foreach( $members_template->members as $m ) {
wp_mail( $m->user_email, $subject, $message );
}
}
}
remove_action( ‘bp_activity_after_save’ , ‘ass_group_notification_activity’ , 50 );
}
add_action( ‘bp_activity_after_save’, ‘cac_email_activity_handler’, 1 );
[/code]
Finally, you’ll need some Javascript to make the AJAX activity submission work correctly. This is really just a copy of what’s in the bp-default JS file, with a few added lines to make it work.
[code language=’php’]
function cac_email_activity_js() {
if ( !bp_is_groups_component() )
return;
?>
var jq = jQuery;
jq(document).ready( function() {
jq(“input#aw-whats-new-submit”).unbind(‘click’);
/* New posts */
jq(“input#aw-whats-new-submit”).click( function() {
var button = jq(this);
var form = button.parent().parent().parent().parent();
form.children().each( function() {
if ( jq.nodeName(this, “textarea”) || jq.nodeName(this, “input”) )
jq(this).attr( ‘disabled’, ‘disabled’ );
});
jq( ‘form#’ + form.attr(‘id’) + ‘ span.ajax-loader’ ).show();
/* Remove any errors */
jq(‘div.error’).remove();
button.attr(‘disabled’,’disabled’);
/* Default POST values */
var object = ”;
var item_id = jq(“#whats-new-post-in”).val();
var content = jq(“textarea#whats-new”).val();
var mailme = jq(“#cac_activity_mail:checked”).val();
/* Set object for non-profile posts */
if ( item_id > 0 ) {
object = jq(“#whats-new-post-object”).val();
}
jq.post( ajaxurl, {
action: ‘post_update’,
‘cookie’: encodeURIComponent(document.cookie),
‘_wpnonce_post_update’: jq(“input#_wpnonce_post_update”).val(),
‘content’: content,
‘object’: object,
‘mailme’: mailme,
‘item_id’: item_id
},
function(response)
{
jq( ‘form#’ + form.attr(‘id’) + ‘ span.ajax-loader’ ).hide();
form.children().each( function() {
if ( jq.nodeName(this, “textarea”) || jq.nodeName(this, “input”) )
jq(this).attr( ‘disabled’, ” );
});
/* Check for errors and append if found. */
if ( response[0] + response[1] == ‘-1’ ) {
form.prepend( response.substr( 2, response.length ) );
jq( ‘form#’ + form.attr(‘id’) + ‘ div.error’).hide().fadeIn( 200 );
button.attr(“disabled”, ”);
} else {
if ( 0 == jq(“ul.activity-list”).length ) {
jq(“div.error”).slideUp(100).remove();
jq(“div#message”).slideUp(100).remove();
jq(“div.activity”).append( ‘
- ‘ );
}
jq(“ul.activity-list”).prepend(response);
jq(“ul.activity-list li:first”).addClass(‘new-update’);
jq(“li.new-update”).hide().slideDown( 300 );
jq(“li.new-update”).removeClass( ‘new-update’ );
jq(“textarea#whats-new”).val(”);
jq(“#cac_activity_mail”).removeAttr(‘checked’);
/* Re-enable the submit button after 8 seconds. */
setTimeout( function() { button.attr(“disabled”, ”); }, 8000 );
}
});
return false;
});
});
New BuddyPress plugin: BP Import Blog Activity
I wrote a BuddyPress plugin today that is very ugly. It imports activity into BuddyPress from blog posts and comments that occurred before you had BuddyPress installed. It’s ugly because it’s sloppily coded and extremely inefficient and likely to hit PHP memory limits every time you run it. But it does the job, so I thought I’d post it and share it with others.
New BuddyPress plugin: BP MPO Activity Filter
In the past I and others have experienced some problems with the way that More Privacy Options for WPMu interacts with BuddyPress – or, to be more exact, with the way that the two don’t recognize each other. Blogs marked as private via MPO were getting plastered all over the public activity streams. In the past I have suggested some unpleasant but more or less functional core hacks, but now I’ve developed a plugin that does the job in the right way. It’s called … drumroll … BP MPO Activity Filter.
New BuddyPress plugin: BP Include Non-Member Comments
I wrote a plugin this afternoon that solves a small but potentially annoying limitation of BuddyPress: its inability to show comments from non-members in the sitewide activity stream. In a streak of extreme creativity, I dubbed the plugin “BP Include Non-Member Comments”. Read more about it, and download it for your own use, here.
New version of BuddyPressActivity for MediaWiki
Ding ding ding. Soup’s on. And by soup I mean version 0.2 of BuddyPressActivity, a MediaWiki extension I wrote.
Read more about it, and get the code, over at the CUNY Academic Commons dev blog.
Removing previous comment edits from BuddyPress activity – a plugin
Another BuddyPress plugin for you. This one makes sure that you don’t get multiple versions of the same comment in your activity streams when a comment is edited. Sounds like a small thing, but it was kind of a bear to program. Anyway, check it out at the CUNY Academic Commons Dev Blog.
New MediaWiki extension: BuddyPressActivity
I just released an extension for MediaWiki that publishes wiki edits to the various activity streams native to BuddyPress. You can learn more about this bit of extreme coolness at the CUNY Academic Commons Dev Blog.