zirow (@zirow)

Forum Replies Created

Viewing 6 replies - 1 through 6 (of 6 total)

  • zirow
    Participant

    @zirow

    I’ve tried @robin-w snippit above but didnt work with my current wordpress version(latest one according to the date of my post) but i managed to get it working with this snippit if anyone needs it.

    Note: I’m a beginner to wordpress and bbpress so there might be other better ways of doing this.

    function change_role(){
    $user_id = $user->ID ;
    if( current_user_can(‘administrator’)){

    bbp_set_user_role( $user_id, ‘bbp_keymaster’ );

    }
    }
    add_action(‘wp_login’, ‘change_role’);


    zirow
    Participant

    @zirow

    Hello Redbird, i’m kind of lost i cant get where the yellow background is it looks white to me and can you point it out where it is located on that website?

    In reply to: Adding roles

    zirow
    Participant

    @zirow

    I’ve tried it and several other functions on other websites but none of them seemed to work.

    In reply to: Adding roles

    zirow
    Participant

    @zirow

    I’ve added this reply like 3times and everytime i edit it it disappeared and when i try to re-paste it and submit i cant cuz i get a warning for duplication 😛

    I’m pretty sure theirs a better way of doing it but that’s how I did since its the only way I could figure it out

    Open Capabilities.php

    Under “function bbp_get_caps_for_role”
    Add this case along with the other cases

    case bbp_get_tutor_role() :
    $caps = array(

    // Primary caps
    ‘spectate’ => true,
    ‘participate’ => true,

    // Forum caps
    ‘read_private_forums’ => true,

    // Topic caps
    ‘publish_topics’ => true,
    ‘edit_topics’ => true,

    // Reply caps
    ‘publish_replies’ => true,
    ‘edit_replies’ => true,

    // Topic tag caps
    ‘assign_topic_tags’ => true,
    );

    Under:

    function bbp_get_participant_role() {

    // Filter & return
    return apply_filters( ‘bbp_get_participant_role’, ‘bbp_participant’ );
    }

    Add:

    function bbp_get_tutor_role() {

    // Filter & return
    return apply_filters( ‘bbp_get_tutor_role’, ‘bbp_tutor’ );
    }

    Save and close Capabilities.php and open bbpress.php in the plugin directory not the one inside the theme.

    Search for:
    public function roles_init() {

    You will see this code:

    $keymaster = bbp_get_keymaster_role();
    $moderator = bbp_get_moderator_role();
    $participant = bbp_get_participant_role();
    $spectator = bbp_get_spectator_role();
    $blocked = bbp_get_blocked_role();

    // Build the roles into one useful array
    $this->roles[ $keymaster ] = new WP_Role( ‘Keymaster’, bbp_get_caps_for_role( $keymaster ) );

    $this->roles[ $moderator ] = new WP_Role( ‘Moderator’, bbp_get_caps_for_role( $moderator ) );
    $this->roles[ $participant ] = new WP_Role( ‘Participant’, bbp_get_caps_for_role( $participant ) );
    $this->roles[ $spectator ] = new WP_Role( ‘Spectator’, bbp_get_caps_for_role( $spectator ) );
    $this->roles[ $blocked ] = new WP_Role( ‘Blocked’, bbp_get_caps_for_role( $blocked ) );
    }

    So you just want to add these two codes in their:

    $tutor = bbp_get_tutor_role();

    $this->roles[ $tutor ] = new WP_Role( ‘tutor’, bbp_get_caps_for_role( $tutor ) );

    If u want to rename an existing role u added or bbpress default roles u can add this into your functions.php

    Add:

    function ntwb_bbpress_custom_role_names() {

    return array(

    // Keymaster

    bbp_get_keymaster_role() => array(

    ‘name’ => ‘Administrator’,

    ‘capabilities’ => bbp_get_caps_for_role( bbp_get_keymaster_role() )

    ),

    // Moderator

    bbp_get_moderator_role() => array(

    ‘name’ => ‘Moderator’,

    ‘capabilities’ => bbp_get_caps_for_role( bbp_get_moderator_role() )

    ),

    // Participant

    bbp_get_participant_role() => array(

    ‘name’ => ‘Member’,

    ‘capabilities’ => bbp_get_caps_for_role( bbp_get_participant_role() )

    ),

    bbp_get_tutor_role() => array(

    ‘name’ => ‘Member2’,

    ‘capabilities’ => bbp_get_caps_for_role( bbp_get_tutor_role() )

    ),

    // Spectator

    bbp_get_spectator_role() => array(

    ‘name’ => ‘Spectator’,

    ‘capabilities’ => bbp_get_caps_for_role( bbp_get_spectator_role() )

    ),

    // Blocked

    bbp_get_blocked_role() => array(

    ‘name’ => ‘Blocked’,

    ‘capabilities’ => bbp_get_caps_for_role( bbp_get_blocked_role() )

    )

    );

    }

    In reply to: Adding roles

    zirow
    Participant

    @zirow

    I’ve added a reply on how to add the roles although im unable to see it on my browser and when i try to readd my reply it says its a duplicate replay can you please tell me if u can see my previous reply or what?

    In reply to: Adding roles

    zirow
    Participant

    @zirow

    I managed to get it working through the files.

Viewing 6 replies - 1 through 6 (of 6 total)