Skip to:
Content
Pages
Categories
Search
Top
Bottom

bbp_get_user_role_map filter not working


  • ptrck_r
    Participant

    @ptrck_r

    Hi, I added a new wordpress role and would like it to map new users not to the participant role but rather to spectator.

    So I added this filter in my functions.php.

    add_filter('bbp_get_user_role_map', 'assign_spectator_role');
      function assign_spectator_role($roles) {
        $roles['mynewrole'] = bbp_get_spectator_role(); 
      return (array) $roles;
    }

    Problem is that this filter does not get executed.
    If I add my role directly in the bbp_get_user_role_map function it works but not with the filter.
    The tools function ‘remap_roles’ also works fine.

    Any ideas how I can get it to work?

    Cheers.

Viewing 1 replies (of 1 total)

  • ptrck_r
    Participant

    @ptrck_r

    [Solved]

    If anybody hasthe same problem, I solved it by creating a small plugin out of the code so it’ll load on time.

    <?php
    /*
    Plugin Name: FilterBbRoleMap
    */
    
    if(!class_exists('FilterBbRoleMap')) {
    	class FilterBbRoleMap
    	{
    		public function __construct()
    		{
    			add_filter('bbp_get_user_role_map', 'add_spectator_role');
    			function add_spectator_role($role_map) {
    				$role_map['prefix_spectator'] = bbp_get_spectator_role();
    				return $role_map;
    			}
    		}
    	}
    
    	$FilterBbRoleMap = new FilterBbRoleMap();
    }
Viewing 1 replies (of 1 total)
  • You must be logged in to reply to this topic.
Skip to toolbar