Skip to:
Content
Pages
Categories
Search
Top
Bottom

Remove Participant Role Capabilities


  • danielleoverman
    Participant

    @danielleoverman

    I’d like to remove the capability for participants to create and edit topics. They should keep their reply capabilities.

    I’m using this code (along with attempting to use a couple different solutions which did not work), but I haven’t found anything that works. Can someone point me in the right direction? No plugins, i’m just looking for working code.


    add_filter( 'bbp_get_caps_for_role', 'ST_add_role_caps_filter', 10, 2 );

    function ST_add_role_caps_filter( $caps, $role ){
    if( $role == bbp_get_participant_role() ) {
    $caps ['publish_topics']= false ;
    }
    return $caps;
    }

Viewing 1 replies (of 1 total)

  • danielleoverman
    Participant

    @danielleoverman

    Solved, found this code snipped from a previous post https://bbpress.org/forums/topic/prevent-users-from-creating-topics-2/ which removed the topic form for everyone but admins and moderators.


    add_filter( 'bbp_current_user_can_access_create_topic_form' , 'rew_only_mods' , 10 , 1) ;
    function rew_only_mods ($retval) {
    // Users need to earn access
    $retval = false;
    //check if admin
    if ( bbp_is_user_keymaster() ) {
    $retval = true;
    }
    //check if moderator
    $role = bbp_get_user_role( get_current_user_id());
    if ($role == 'bbp_moderator') {
    $retval = true;
    }
    // Allow access to be filtered
    return (bool) apply_filters( 'rew_current_user_can_access_create_topic_form', (bool) $retval );
    }

Viewing 1 replies (of 1 total)
  • You must be logged in to reply to this topic.
Skip to toolbar