Follow development on the latest release

Accessing user metadata in BP 1.3

BuddyPress plugin authors updating their plugins for BuddyPress 1.3 will want to be aware of some recent changes to the way that user metadata is stored and accessed throughout BuddyPress.

Usermeta has been one of the final issues standing in the way of running separate BuddyPress instances on a single WordPress network. BP stores a variety of user metadata in WP’s global usermeta table, but multi-BP would require this usermeta to be stored separately for each BP instance. The solution, implemented in r4372 and r4378, is to introduce a wrapper function bp_get_user_meta_key(), which allows user meta keys to be filtered by plugins. See #2952 for more information.

What this means for you: BP user metadata remains unchanged, and your plugins that depend on this metadata will continue to work as expected in BP 1.3. However, in order for your plugin to be compatible with multi-BP, you will have to use bp_get_user_meta_key() whenever you fetch or store usermeta data. For example, let’s say you have a Favorite Groups plugin, and a function that stores a user’s favorite groups in a usermeta called ‘bp_favorite_groups’. Your _user_meta() calls should look like this:
$favorites = get_user_meta( $user_id, bp_get_user_meta_key( 'bp_favorite_groups' ), true );

At the moment, there are no plans (or patches) to make this a core feature of BP. But it’s getting close to the point where a plugin would pretty easily be able to make it happen. See wpmuguru’s proposed plugin from #2952, for instance: http://buddypress.trac.wordpress.org/attachment/ticket/2952/bp-multi-network.php (This plugin won’t work as it stands, but it suggests how such a thing would be done.)