Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Fix for s2member and bbPress 2.2 plus new roles
<?php
/*
Plugin Name: Fix bbPress roles for s2member
Plugin URI: http://roughsmootheng.in
Version: 1.0
Description: This plugin adds s2member roles to the user_role_map for bbPress.
Author: Darren Ethier
Author URI: http://www.roughsmootheng.in
*/
add_action('plugins_loaded', 'rr_add_s2_roles_to_bbpress');
function rr_add_s2_roles_to_bbpress() {
add_filter( 'bbp_get_user_role_map', 'rr_add_s2_roles_to_map');
}
function rr_add_s2_roles_to_map($current_map) {
//first we need to get s2member roles
$num_levels = $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["levels"];
if ( empty($num_levels) )
$num_levels = 4;
//default bbp role
$default_role = bbp_get_default_role();
for ( $i=0; $i <= $num_levels; $i++ ) {
$s2mem_map['s2member_level'.$i] = $default_role;
}
$new_map = array_merge($s2mem_map, $current_map);
return $new_map;
}
@nerrad

This comment has been minimized.

Copy link
Owner Author

nerrad commented Nov 21, 2012

this gist should become unneeded with the release of bbPress 2.2.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.