Forked from nerrad/fix-bbpress-roles-in-s2member.php
Created
November 21, 2012 14:23
-
-
Save labsecrets/4125085 to your computer and use it in GitHub Desktop.
Fix for s2member and bbPress 2.2 plus new roles
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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