Skip to:
Content
Pages
Categories
Search
Top
Bottom

2.6 doesn’t recognise existing WP forum roles


  • scabbrox
    Participant

    @scabbrox

    Hello there

    I’ve run into an issue with updating our website’s forum from 2.5.14 to 2.6.

    We have been using a set of wp roles as additional forum roles on our site for about 2 years now to allow us to have more tiers of membership and administrator roles visible in the forums rather than the standard 5. This has worked fine up till now but when we apply the 2.6 update these roles are no longer recognised as additional forum roles, though they still exists as wordpress roles.

    I’m not entirely sure how these roles were initially flagged as forum roles, but they were simply created by duplicating the existing forum roles and then renaming them.

    I’ve checked the functions.file for our child theme and there’s nothing in there that would be assigning them so I’m assuming it’s because of differences in the capabilities-php file where some of the previous capabilities are listed as deprecated in 2.6.

    Any idea how we can fix this as currently we’re unable to upgrade until we can retain the roles.

    Thanks for your assistance in this matter.

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

  • John James Jacoby
    Keymaster

    @johnjamesjacoby

    Hey there! Sorry that 2.6 is giving you trouble.

    bbPress roles are somewhat tricky, but not too much has changed, so it shouldn’t be too hard for us to figure it out.

    We’ll need to see the code that you used to make your custom Roles. If you can include it or link to it here, that will be really helpful.


    scabbrox
    Participant

    @scabbrox

    Hi there and thanks for the reply.

    The trouble is I’m not entirely sure how we did it as it was a while ago and the person that did it is no longer with us.

    I’m not seeing anything in functions.php which is where I understand that code is normally put for this so I’m assuming it’s in the capabilities.php file that the update is overriding as this does refer to treating wp_roles as bbpress roles.

    I can send a copy of the capabilities file (not seeing an upload button) or perhaps you can give me an idea where else to look?

    Sorry to be so vague, but it works fine with the previous version of bbpress so I’m guessing it’s something that gets overwritten when I update.

    The roles were created by clicking duplicate on a bbpress role and then changing the name, but if I try that now it just created a wp-role and not a forum role.


    scabbrox
    Participant

    @scabbrox

    I think I may have found it….

    It’s in the bbpress.php file (of the pre-update version). Is this it?

    ———–
    /**
    * The main function responsible for returning the one true bbPress Instance
    * to functions everywhere.
    *
    * Use this function like you would a global variable, except without needing
    * to declare the global.
    *
    * Example: <?php $bbp = bbpress(); ?>
    *
    * @return The one true bbPress Instance
    */
    function bbpress() {
    return bbpress::instance();
    }

    /**
    * Hook bbPress early onto the ‘plugins_loaded’ action.
    *
    * This gives all other plugins the chance to load before bbPress, to get their
    * actions, filters, and overrides setup without bbPress being in the way.
    */
    if ( defined( ‘BBPRESS_LATE_LOAD’ ) ) {
    add_action( ‘plugins_loaded’, ‘bbpress’, (int) BBPRESS_LATE_LOAD );

    // “And now here’s something we hope you’ll really like!”
    } else {
    bbpress();
    }

    endif; // class_exists check

    function add_new_roles( $bbp_roles )
    {
    $bbp_roles[‘bbp_trial’] = array(
    ‘name’ => ‘Trial’,
    ‘capabilities’ => custom_capabilities( ‘bbp_trial’ )
    );

    $bbp_roles[‘bbp_warlord’] = array(
    ‘name’ => ‘Warlord’,
    ‘capabilities’ => custom_capabilities( ‘bbp_warlord’ )
    );

    $bbp_roles[‘bbp_general’] = array(
    ‘name’ => ‘General’,
    ‘capabilities’ => custom_capabilities( ‘bbp_general’ )
    );

    $bbp_roles[‘bbp_member’] = array(
    ‘name’ => ‘Member’,
    ‘capabilities’ => custom_capabilities( ‘bbp_member’ )
    );

    $bbp_roles[‘bbp_council_member’] = array(
    ‘name’ => ‘Council Member’,
    ‘capabilities’ => custom_capabilities( ‘bbp_council_member’ )
    );

    return $bbp_roles;
    }

    add_filter( ‘bbp_get_dynamic_roles’, ‘add_new_roles’, 1 );

    function add_role_caps_filter( $caps, $role )
    {
    if( $role == ‘bbp_trial’ )
    $caps = custom_capabilities( $role );

    if( $role == ‘bbp_warlord’ )
    $caps = custom_capabilities( $role );

    if( $role == ‘bbp_general’ )
    $caps = custom_capabilities( $role );

    if( $role == ‘bbp_member’ )
    $caps = custom_capabilities( $role );

    if( $role == ‘bbp_council_member’ )
    $caps = custom_capabilities( $role );

    return $caps;
    }

    add_filter( ‘bbp_get_caps_for_role’, ‘add_role_caps_filter’, 10, 2 );

    function custom_capabilities( $role )
    {
    switch ( $role )
    {

    /* Capabilities for ‘councilmember’ role */
    case ‘bbp_council_member’:
    return array(
    // Primary caps
    ‘spectate’ => true,
    ‘participate’ => true,
    ‘moderate’ => true,
    ‘throttle’ => true,
    ‘view_trash’ => false,

    // Forum caps
    ‘publish_forums’ => false,
    ‘edit_forums’ => false,
    ‘edit_others_forums’ => false,
    ‘delete_forums’ => false,
    ‘delete_others_forums’ => false,
    ‘read_private_forums’ => true,
    ‘read_hidden_forums’ => true,

    // Topic caps
    ‘publish_topics’ => true,
    ‘edit_topics’ => true,
    ‘edit_others_topics’ => true,
    ‘delete_topics’ => true,
    ‘delete_others_topics’ => true,
    ‘read_private_topics’ => true,

    // Reply caps
    ‘publish_replies’ => true,
    ‘edit_replies’ => true,
    ‘edit_others_replies’ => true,
    ‘delete_replies’ => true,
    ‘delete_others_replies’ => true,
    ‘read_private_replies’ => true,

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

    /* Capabilities for ‘member’ role */
    case ‘bbp_member’:
    return array(
    // Primary caps
    ‘spectate’ => true,
    ‘participate’ => true,
    ‘moderate’ => false,
    ‘throttle’ => false,
    ‘view_trash’ => false,

    // Forum caps
    ‘publish_forums’ => false,
    ‘edit_forums’ => false,
    ‘edit_others_forums’ => false,
    ‘delete_forums’ => false,
    ‘delete_others_forums’ => false,
    ‘read_private_forums’ => true,
    ‘read_hidden_forums’ => false,

    // Topic caps
    ‘publish_topics’ => true,
    ‘edit_topics’ => true,
    ‘edit_others_topics’ => false,
    ‘delete_topics’ => false,
    ‘delete_others_topics’ => false,
    ‘read_private_topics’ => true,

    // Reply caps
    ‘publish_replies’ => true,
    ‘edit_replies’ => true,
    ‘edit_others_replies’ => false,
    ‘delete_replies’ => true,
    ‘delete_others_replies’ => false,
    ‘read_private_replies’ => true,

    // Topic tag caps
    ‘manage_topic_tags’ => false,
    ‘edit_topic_tags’ => false,
    ‘delete_topic_tags’ => false,
    ‘assign_topic_tags’ => true,
    );

    /* Capabilities for ‘warlord’ role */
    case ‘bbp_warlord’:
    return array(
    // Primary caps
    ‘spectate’ => true,
    ‘participate’ => true,
    ‘moderate’ => true,
    ‘throttle’ => true,
    ‘view_trash’ => true,

    // Forum caps
    ‘publish_forums’ => true,
    ‘edit_forums’ => true,
    ‘edit_others_forums’ => true,
    ‘delete_forums’ => true,
    ‘delete_others_forums’ => true,
    ‘read_private_forums’ => true,
    ‘read_hidden_forums’ => true,

    // Topic caps
    ‘publish_topics’ => true,
    ‘edit_topics’ => true,
    ‘edit_others_topics’ => true,
    ‘delete_topics’ => true,
    ‘delete_others_topics’ => true,
    ‘read_private_topics’ => true,

    // Reply caps
    ‘publish_replies’ => true,
    ‘edit_replies’ => true,
    ‘edit_others_replies’ => true,
    ‘delete_replies’ => true,
    ‘delete_others_replies’ => true,
    ‘read_private_replies’ => true,

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

    /* Capabilities for ‘general’ role */
    case ‘bbp_general’:
    return array(
    // Primary caps
    ‘spectate’ => true,
    ‘participate’ => true,
    ‘moderate’ => true,
    ‘throttle’ => true,
    ‘view_trash’ => true,

    // Forum caps
    ‘publish_forums’ => true,
    ‘edit_forums’ => true,
    ‘edit_others_forums’ => true,
    ‘delete_forums’ => true,
    ‘delete_others_forums’ => true,
    ‘read_private_forums’ => true,
    ‘read_hidden_forums’ => true,

    // Topic caps
    ‘publish_topics’ => true,
    ‘edit_topics’ => true,
    ‘edit_others_topics’ => true,
    ‘delete_topics’ => true,
    ‘delete_others_topics’ => true,
    ‘read_private_topics’ => true,

    // Reply caps
    ‘publish_replies’ => true,
    ‘edit_replies’ => true,
    ‘edit_others_replies’ => true,
    ‘delete_replies’ => true,
    ‘delete_others_replies’ => true,
    ‘read_private_replies’ => true,

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

    /* Capabilities for ‘trial’ role */
    case ‘bbp_trial’:
    return array(
    // Primary caps
    ‘spectate’ => true,
    ‘participate’ => true,
    ‘moderate’ => false,
    ‘throttle’ => false,
    ‘view_trash’ => false,

    // Forum caps
    ‘publish_forums’ => false,
    ‘edit_forums’ => false,
    ‘edit_others_forums’ => false,
    ‘delete_forums’ => false,
    ‘delete_others_forums’ => false,
    ‘read_private_forums’ => true,
    ‘read_hidden_forums’ => false,

    // Topic caps
    ‘publish_topics’ => true,
    ‘edit_topics’ => true,
    ‘edit_others_topics’ => false,
    ‘delete_topics’ => false,
    ‘delete_others_topics’ => false,
    ‘read_private_topics’ => true,

    // Reply caps
    ‘publish_replies’ => true,
    ‘edit_replies’ => true,
    ‘edit_others_replies’ => false,
    ‘delete_replies’ => true,
    ‘delete_others_replies’ => false,
    ‘read_private_replies’ => true,

    // Topic tag caps
    ‘manage_topic_tags’ => false,
    ‘edit_topic_tags’ => false,
    ‘delete_topic_tags’ => false,
    ‘assign_topic_tags’ => true,
    );

    break;

    default :
    return $role;
    }
    }


    Robin W
    Moderator

    @robin-w

    yes, that looks like it, and yes it should not be in that part as it gets overwritten. Good that you had a copy !

    so from

    function add_new_roles( $bbp_roles )

    to the end and put this in the functions file of your child theme


    scabbrox
    Participant

    @scabbrox

    Thanks for that.

    Just to be sure is there anything I need to add between the end of the current functions.php in my child theme and the above paste?

    It currently ends like this:

    // usp pro replace underscores with spaces
    function usp_pro_modify_field_value($value) {

    return ucwords(trim(str_replace(‘_’, ‘ ‘, $value)));

    }
    add_filter(‘usp_custom_fields_checkbox_value’, ‘usp_pro_modify_field_value’);
    add_filter(‘usp_custom_fields_radio_value’, ‘usp_pro_modify_field_value’);
    add_filter(‘usp_custom_fields_select_value’, ‘usp_pro_modify_field_value’);
    add_filter(‘acf/settings/remove_wp_meta_box’, ‘__return_false’);


    Robin W
    Moderator

    @robin-w

    yes putting it after that should be fine.

    Just keep a version of the file before the change just in case it errors then you can quickly revert back and report back here !!


    scabbrox
    Participant

    @scabbrox

    Worked great, thanks!


    Robin W
    Moderator

    @robin-w

    great – glad you are fixed !!


    scabbrox
    Participant

    @scabbrox

    Hello again Robin

    Sorry to bother you again but I seem to have a persistent issue that I thought I’d cleared but keeps coming back.

    I’ve noticed that despite now having all my additional forum roles back, assigned and active that each time a user relogs it adds Spectator to their user roles (this is a forum not user role so it should not do that) whilst not changing their forum role.

    The only way to fix this is to change their forum role back to Spectator and then change it once more to Member/Moderator etc, but this doesn’t stick for good as check back in a day or two and they’ve got Spectator listed as a user role again.

    This creates issues with permissions on the site as Spectators can’t see a lot of the content.

    Wondering if you have any idea why it might be adding this role back?


    Robin W
    Moderator

    @robin-w

    can you check

    dashboard>settings>forums

    item – Automatically give registered visitors the xx role

    I suspect you have this checked and set to spectator?


    scabbrox
    Participant

    @scabbrox

    Hi and thanks for the quick reply.

    It is indeed set to do that, it always has been in the past to allow new applicants the ability to see areas of the forum that are public and make an application to join.

    The difference is now it’s adding it also to anyone who also has a role assigned manually.

    I can try turning it off but am concerned this may impact the ability of genuine Spectators (potential applicants and former members) to make applications and see the public forums.

    I’ll test it and get back to you if needed.


    Robin W
    Moderator

    @robin-w

    hmmm…not sure why it is doing that – clearly it thinks they don’t have a role.


    scabbrox
    Participant

    @scabbrox

    Seems it works even without a role so looks like it’s sorted. Will let you know if it recurs. Thanks again.


    scabbrox
    Participant

    @scabbrox

    The only reason I can think of is that before the extra ranks were part of BBPress.php file and now they are in the child themes functions.php instead so maybe it’s not loading these roles in time?


    Robin W
    Moderator

    @robin-w

    no, 2.6 does roles differently – so in effect turning that off fixed it for your logged in users. If non logged in see all that you want, then that’s fine, and you are fixed.

    If not come back

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