• Resolved fscbmwcca

    (@fscbmwcca)


    Is there anyway to hide the menu item if the user does not have access?
    When clicked it shows “Sorry, you are not allowed to access this page.”

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Sayontan Sinha

    (@sayontan)

    Thank you for pointing this out. This will need a small change.

    If you can wait for the next version I will put it in there. Otherwise you can try this:

    1. Go to wp-content/plugins/photonic/photonic.php, line 222. You will see this:
      
      function add_admin_menu() {
      	global $photonic_options_manager;
      	$this->options_page_name = add_menu_page('Photonic', 'Photonic', 'edit_posts', 'photonic-options-manager', array(&$photonic_options_manager, 'render_settings_page'), plugins_url('include/images/Photonic-20-gr.png', __FILE__));
      	$this->settings_page = add_submenu_page('photonic-options-manager', esc_html__('Settings', 'photonic'), esc_html__('Settings', 'photonic'), 'edit_theme_options', 'photonic-options-manager', array(&$photonic_options_manager, 'render_settings_page'));
      	$this->getting_started_page = add_submenu_page('photonic-options-manager', 'Getting Started', 'Getting Started', 'edit_posts', 'photonic-getting-started', array(&$photonic_options_manager, 'render_getting_started'));
      	$this->authentication_page = add_submenu_page('photonic-options-manager', 'Authentication', 'Authentication', 'edit_theme_options', 'photonic-auth', array(&$photonic_options_manager, 'render_authentication'));
      	$this->gutenberg_page = add_submenu_page('photonic-options-manager', esc_html__('Prepare for Gutenberg', 'photonic'), '<div style="color: #c66">'.esc_html__('Prepare for Gutenberg', 'photonic').'</div>', 'edit_posts', 'photonic-gutenberg', array(&$photonic_options_manager, 'render_gutenberg'));
      	$this->helper_page = add_submenu_page('photonic-options-manager', 'Helpers', 'Helpers', 'edit_posts', 'photonic-helpers', array(&$photonic_options_manager, 'render_helpers'));
      }
      
    2. Replace that whole block with this:
      
      function add_admin_menu() {
      	global $photonic_options_manager;
      	if (current_user_can('edit_theme_options')) {
      		$parent_slug = 'photonic-options-manager';
      	}
      	else if (current_user_can('edit_posts')) {
      		$parent_slug = 'photonic-getting-started';
      	}
      
      	if (!empty($parent_slug)) {
      		$this->options_page_name = add_menu_page('Photonic', 'Photonic', 'edit_posts', $parent_slug, array(&$photonic_options_manager, 'render_settings_page'), plugins_url('include/images/Photonic-20-gr.png', __FILE__));
      		$this->settings_page = add_submenu_page($parent_slug, esc_html__('Settings', 'photonic'), esc_html__('Settings', 'photonic'), 'edit_theme_options', 'photonic-options-manager', array(&$photonic_options_manager, 'render_settings_page'));
      		$this->getting_started_page = add_submenu_page($parent_slug, 'Getting Started', 'Getting Started', 'edit_posts', 'photonic-getting-started', array(&$photonic_options_manager, 'render_getting_started'));
      		$this->authentication_page = add_submenu_page($parent_slug, 'Authentication', 'Authentication', 'edit_theme_options', 'photonic-auth', array(&$photonic_options_manager, 'render_authentication'));
      		$this->gutenberg_page = add_submenu_page($parent_slug, esc_html__('Prepare for Gutenberg', 'photonic'), '<div style="color: #c66">'.esc_html__('Prepare for Gutenberg', 'photonic').'</div>', 'edit_posts', 'photonic-gutenberg', array(&$photonic_options_manager, 'render_gutenberg'));
      		$this->helper_page = add_submenu_page($parent_slug, 'Helpers', 'Helpers', 'edit_posts', 'photonic-helpers', array(&$photonic_options_manager, 'render_helpers'));
      	}
      }
      

    Be careful with the above code though … if you make a mistake it can cause you to get locked out.

    Thread Starter fscbmwcca

    (@fscbmwcca)

    Thanks for the prompt reply. I may give it a shot with a test site!

    Plugin Author Sayontan Sinha

    (@sayontan)

    I have addressed this in version 2.28.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘No Access but Displays in Menu on the backend’ is closed to new replies.