WordPress.org

Ready to get started?Download WordPress

Forums

Allow editors to update custom options pages (1 post)

  1. Carl
    Member
    Posted 2 years ago #

    According to this ticket there was a bug in the Settings API so that regardless of the role capability set in the add_submenu_page() call the required capability would still be "manage_options".

    I'm trying to use the implemented patch but with no success. Could someone take a look at my code and try to help me out?

    The following code runs in /mu-plugins/ which might be of relevance.

    function set_option_page_capability() {
    	return 'edit_theme_options';
    }
    add_action('admin_menu', 'create_menu');
    function create_menu() {
    	global $array_of_option_pages; //set in the_current_theme/functions.php
    	foreach ($array_of_option_pages as $settings_page => $options) {
    		$settings_page_slug = sanitize_title($settings_page);
    		add_filter('option_page_capability_'.$settings_page_slug, 'set_option_page_capability');
    		add_submenu_page(
    			'themes.php', 			//parent menu
    			$settings_page, 		//page title
    			$settings_page, 		//menu title
    			set_option_page_capability(),	//role capability requirement
    			$settings_page_slug, 		//url
    			'render_settings_page' 		//display output function callback
    		);
    	}
    }

Topic Closed

This topic has been closed to new replies.

About this Topic