Skip to:
Content
Pages
Categories
Search
Top
Bottom

custom role is not working


  • gusrb84
    Participant

    @gusrb84

    I just wanted to give general users capabilities to delete their own topics/replies, so I added custom role for bbpress forums.

    I followed: http://codex.bbpress.org/custom-capabilities/, to add ‘PPH General User’ and I see the forum role in Edit User page. I also changed Auto role in Forums Settings so that the website can automatically give registered visitor ‘PPH General User’ role.

    In ‘usermeta’ database, I see that it assigned ‘a:1:{s:16:”pph_general_user”;b:1;}’ to capabilities key. It is good so far.

    However, when I open the forum with PPH General User account, all bbpress capabilities for ‘PPH General User’ are disabled.

    Even reading a forum shows nothing with body class = “error404 logged-in”
    If I change the user account to Participant, all bbpress functions work as expected.
    (with body class = “forum bbpress single single-forum postid-42 logged-in”)

    With PPH General Account,

    
    $cur_user_id = get_current_user_id();
    $roles=get_userdata( $cur_user_id );
    echo 'User Role:'; print_r($roles->roles); echo '<br />';
    $role_caps = bbp_get_caps_for_role($roles->roles[0]);
    echo 'User Cap:'; print_r($role_caps); echo '<br />';
    if (current_user_can( 'spectate')){echo 'You can spectate';}
    	else{echo 'You cannot spectate';};
    

    prints out:
    User Role:Array ( [0] => pph_general_user )
    User Cap:Array ( [spectate] => 1 [participate] => 1 [read_private_forums] => 1 [publish_topics] => 1 [edit_topics] => 1 [delete_topics] => 1 [read_private_topics] => 1 [publish_replies] => 1 [edit_replies] => 1 [delete_replies] => 1 [read_private_replies] => 1 [manage_topic_tags] => 1 [edit_topic_tags] => 1 [delete_topic_tags] => 1 [assign_topic_tags] => 1 )
    You cannot spectate

    If the account is changed to ‘Participant’ then it prints out:
    User Role:Array ( [0] => bbp_participant )
    User Cap:Array ( [spectate] => 1 [participate] => 1 [read_private_forums] => 1 [publish_topics] => 1 [edit_topics] => 1 [publish_replies] => 1 [edit_replies] => 1 [assign_topic_tags] => 1 )
    You can spectate

    Someone please help me. I spent so many hours debugging this..

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)

You must be logged in to reply to this topic.