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.

BP Lotsa Feeds

BP Lotsa Feeds adds a whole bunch of RSS feeds to your installation of BuddyPress. The following feeds are included with BP Lotsa Feeds (followed by the URL pattern where the feeds can be found):

INDIVIDUAL MEMBERS

  • Networkwide comments by an individual member (/members/username/activity/comments/feed)
  • Networkwide blog posts by an individual member (/members/username/activity/blogposts/feed)
  • Activity updates by an individual member (/members/username/activity/updates/feed)
  • An individual member’s friendship connections (/members/username/activity/friendships/feed)
  • Forum topics started by an individual member (/members/username/activity/forumtopics/feed)
  • Forum replies by an individual member (/members/username/activity/forumreplies/feed)
  • All forum activity by a member (a combination of the previous two feeds) (/members/username/activity/forums/feed)

INDIVIDUAL GROUPS

  • A group’s activity updates (/groups/groupname/updates/feed)
  • New forum topics in a given group (/groups/groupname/forumtopics/feed)
  • Forum replies in a given group (/groups/groupname/forumreplies/feed)
  • All forum activity in a given group (a combination of the previous two feeds) (/groups/groupname/forums/feed)
  • A group’s new members (/groups/groupname/membership/feed)

FORUMS

  • Individual forum topic posts (/groups/groupname/forum/topic/topicslug/feed)

You can make any of these feeds inaccessible by defining the corresponding DISABLE constant in plugins/bp-custom.php or wp-config.php, e.g.

define( 'BPLF_DISABLE_GROUP_UPDATES_FEED', true );

See bp-lotsa-feeds.php for the proper constant names.

Hooks and filters are in place so that you can add custom feeds and feed templates.

Follow the plugin’s development at http://github.com/boonebgorges/bp-lotsa-feeds

Instructions

  1. Upload the bp-lotsa-feeds directory to your WP plugins folder and activate

Thanks to Red Rover, the sponsor of this plugin.

Download the plugin here.

BP Lotsa Feeds has been downloaded 1,100 times. Are you using this plugin? Consider a donation.

Version history

1.0 – September 28, 2010
Initial release

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.

Get BP External Activity here.

BP External Activity

BP External Activity allows admins to import data from an arbitrary RSS feed into their BuddyPress sitewide activity stream. For example, you might use the plugin to add activity items for edits on a MediaWiki installation.

The plugin imports RSS feeds every hour. You may find that you need to decrease your Simplepie cache time to make it work:

add_filter( 'wp_feed_cache_transient_lifetime', create_function('$a', 'return 600;') );

reduces the RSS cache to ten minutes, for example. Put that in your bp-custom.php file if you are having problems with the plugin.

At the moment, the plugin uses the Author field from the RSS feed to look for a matching author in your WP database. If it doesn’t find one, it uses the unlinked text ‘A user’, as in ‘A user edited the wiki page…’.

Instructions

  1. Upload the bp-external-activity directory to your WP plugins folder and activate
  2. Open loader.php and replace the sample feed data with your own. Read the inline documentation carefully.

Future versions of the plugin will have a real admin interface (no PHP knowledge necessary), more sophisticated matching of feed authors with BP members, and the ability to attach feeds to groups.

Thanks to Andy Peatling, whose External Group Blogs served as the inspiration for a good part of the code.

Download the plugin here.

BP External Activity has been downloaded 1,067 times. Are you using this plugin? Consider a donation.

Version history

1.0 – May 25, 2010
Initial release

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.


function cac_email_activity_checkbox() {
	if ( !bp_is_groups_component() )
		return;
	?>

<label for="cac_activity_mail">
		Email this update to all group members? 
		<input type="checkbox" name="cac_activity_mail" id="cac_activity_mail" value="mailme" />
	</label>
	<?php
}
add_action( 'bp_activity_post_form_options', 'cac_email_activity_checkbox' );

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 :)


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&amp;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 );

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.

function cac_email_activity_js() {
	if ( !bp_is_groups_component() )
		return;
	?>
	<script type="text/javascript">

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( '<ul id="activity-stream" class="activity-list item-list">' );
				}

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;
	});
	});

</script>
	<?php 
}
add_action( 'bp_activity_post_form_options', 'cac_email_activity_js', 999 );

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.

Read more about it, along with a bunch of warnings, here.

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.

Check it out here.

BP MPO Activity Filter

More Privacy Options is a plugin for WPMu that allows blog owners to fine-tune their blog’s privacy settings, expanding on the default privacy settings offered in the WP core. Putting this plugin together with BuddyPress has been problematic, however, because BuddyPress is not built to recognize the new privacy settings defined by MPO. As a result, even private blog posts get put into the public activity feed.

This plugin, BP MPO Activity Filter, does just what the name suggests: it filters BuddyPress activity feeds (wherever bp_has_activities appears) and filters the output based on the privacy settings of the source blogs. For example, if a blog is set to be visible only to logged in members of the community, BP MPO Activity Filter will only display activity items corresponding to that blog (both posts and comments) to users who are logged in. Sitewide administrators will have an unfiltered activity stream.

I borrowed the idea, and a little bit of the code, from this plugin. Because of incompatibilities with the way earlier versions of BP stored activity item data, this plugin will not work properly with installations of BP 1.1.3 or earlier (nor will it work on data created on that version of BP, even if the core software is updated).

Download the plugin here.

BP MPO Activity Filter has been downloaded 1,750 times. Are you using this plugin? Consider a donation.

Version history

1.0 – February 7, 2010
Initial release

1.0.1 – February 22, 2010
Added code to ensure that plugin is not loaded before BuddyPress is
Updated readme file to include more information on compatibility with BP < 1.2

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.