Forum Replies Created

Viewing 6 replies - 1 through 6 (of 6 total)
  • Thread Starter thomasfw

    (@thomasfw)

    I’m not going to waste my time repeating the obvious, just take a look at one of the many recent negative reviews if you need a full breakdown.

    Getting rid of all the bloat that’s just been added would be a good start.

    Cheers

    Thread Starter thomasfw

    (@thomasfw)

    You’re completely right, not sure how I overlooked that one.

    Cheers

    Thread Starter thomasfw

    (@thomasfw)

    Yep the first block would go in my theme or plugin.

    The second block would go in settings.php in addition to the filter that was added in 3.1.8.

    Thanks

    (Have you thought about getting up on github? I’d be happy to contribute)

    Thread Starter thomasfw

    (@thomasfw)

    Hi Robin

    Sorry to bother you again! I’ve realised that whilst the above will allow users with the filtered capability to access the settings page, they won’t be able to actually submit any of the forms as they don’t have the correct cap for that (manage_options).

    I’ve added a fix for this below. It allows us to specify the cap required to submit a particular option form. So I could allow keymasters to submit only the ‘group settings’ form using..

    add_filter('rpg_plugin_group_settings_capability', 'mytheme_bbp_private_groups_settings_access');
    function mytheme_bbp_private_groups_settings_access($cap) {
    	return 'publish_forums';
    }

    It would go in includes/settings.php just after line 414 (after rpg_register_settings() ).

    // ALLOW US TO SPECIFY WHO CAN MANAGE CERTAIN SETTINGS:
    // ---------------------------------------------------------------------------------------
    function rpg_forum_page_capability( $capability ) {
    	$capability = apply_filters('rpg_plugin_forum_settings_capability','manage_options');
        return $capability;
    }
    function rpg_general_page_capability( $capability ) {
    	$capability = apply_filters('rpg_plugin_general_settings_capability','manage_options');
        return $capability;
    }
    function rpg_group_page_capability( $capability ) {
    	$capability = apply_filters('rpg_plugin_group_settings_capability','manage_options');
        return $capability;
    }
    function rpg_roles_page_capability( $capability ) {
    	$capability = apply_filters('rpg_plugin_roles_settings_capability','manage_options');
        return $capability;
    }
    add_filter( 'option_page_capability_rpg_forum_settings', 	'rpg_forum_page_capability' );
    add_filter( 'option_page_capability_rpg_general_settings', 	'rpg_general_page_capability' );
    add_filter( 'option_page_capability_rpg_group_settings', 	'rpg_group_page_capability' );
    add_filter( 'option_page_capability_rpg_roles_settings', 	'rpg_roles_page_capability' );
    // ---------------------------------------------------------------------------------------

    Uses this hook: https://developer.ww.wp.xz.cn/reference/hooks/option_page_capability_option_page/

    Thanks again

    Thread Starter thomasfw

    (@thomasfw)

    Awesome, thanks very much!

    Thread Starter thomasfw

    (@thomasfw)

    Thanks Robin, much appreciated. Basically the filter will allow anyone who hooks into it to change the capability. So with the new filter it’s possible to add the following into my theme’s functions.php or elsewhere..

    // Enable Keymaster access to the settings page:
    add_filter('rpg_plugin_settings_capability', 'mytheme_bbp_private_groups_settings_access');
    function mytheme_bbp_private_groups_settings_access($cap)
    {
    	return 'publish_forums';
    }

    The value of $cap will default to ‘manage_options’ if the filter isn’t hooked into, otherwise it’ll be the value returned from the hooked function (see above example). $cap replaces the hardcoded ‘manage_options’ string in the add_submenu_page() function.

    Cheers

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