Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save labsecrets/4125085 to your computer and use it in GitHub Desktop.
Save labsecrets/4125085 to your computer and use it in GitHub Desktop.
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;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment