Title: Custom menu permissions issues
Last modified: August 21, 2016

---

# Custom menu permissions issues

 *  Resolved [erikstainsby](https://wordpress.org/support/users/erikstainsby/)
 * (@erikstainsby)
 * [12 years, 10 months ago](https://wordpress.org/support/topic/custom-menu-permissions-issues/)
 * I have read the docs for add_submenu_page a thousand times. This is getting very
   old.
    I have a custom top-level menu “Site Manager” which I mean to poopulate
   with half a dozen custom plugins. Only I can’t seem to get past hooking up the
   first child. (The top-level has no direct child menu items, just an information
   page.)
    1. I hook ‘admin_menu’ in _init (class-based php file)
    2. I see error_log msgs for _init, then add_ci_submenu, then the returned suffix
       is logged
    3. at which point the screen dies with the proverbial You do not have sufficient
       permissions… yada yada
    4. I proceed to rip out my hair
 * What am I doing wrong? It seems so baldly simple. No?
 * Here’s my code:
 *     ```
       class ContactInfo {
   
       	var $suffix;	// menu tag suffix 
   
       	public function __construct() {
       		add_action( 'init', array( &$this, '_init' ));
       	}
   
       	public function _init() {
   
       		error_log(__FUNCTION__);
   
       		wp_register_sidebar_widget('ci-widget','Contact Information',array(&$this,'ci_widget'));
   
       		if( is_admin()) {
       			add_action( 'admin_enqueue_scripts', array( &$this, 'admin_enqueue_styles_scripts' ));
       			add_action( 'admin_menu', array( &$this,'add_ci_submenu' ));
       			add_action( 'wp_ajax_coop-save-ci-change', array( &$this, 'ci_admin_save_changes'));
       		}
       	}
   
       	public function frontside_enqueue_styles_scripts() {
       		error_log(__FUNCTION__);
       		wp_enqueue_style( 'coop-ci' );
       	//	wp_enqueue_script( 'coop-ci-js' );
       	}
   
       	public function admin_enqueue_styles_scripts($hook) {
   
       		error_log(__FUNCTION__);
       		error_log($hook);
   
       	//	if( 'toplevel_page_site-manager' !== $hook && $this->suffix !== $hook ) {
       	//		return;
       	//	}
   
       		wp_register_script( 'coop-ci-admin-js', plugins_url( '/js/ci-admin.js',__FILE__), array('jquery'));
       		wp_register_style( 'coop-ci-admin', plugins_url( '/css/ci-admin.css', __FILE__ ), false );
   
       		wp_enqueue_style( 'coop-ci-admin' );
       		wp_enqueue_script( 'coop-ci-admin-js' );
   
       	}
   
       	public function add_ci_submenu() {
   
       		error_log(__FUNCTION__);
   
       		$this->suffix = add_submenu_page( 'site-manager', 'Contact Information', 'Contact Information', 'manage_options', 'contact-information', array(&$this,'admin_ci_settings_page'));
   
       		error_log('suffix: '. $this->suffix);
       	}
   
               public function admin_ci_settings_page() {
   
       		error_log(__FUNCTION__);
   
       	//	if( ! current_user_can('manage_local_site') ) die('You do not have required permissions to view this page');
   
       		$out = array();
       		$out[] = '<div class="wrap">';
       		$out[] = '<div id="icon-options-general" class="icon32">';
       		$out[] = '<br>';
       		$out[] = '</div>';
       		$out[] = '<h2>Contact Information parameters</h2>';
   
       		$out[] = '<p>Contact info used on the front page of the site</p>';
   
                       [snip]
   
                       echo implode("\n",$out);
       	}
       }
       /* end of class */
       ```
   
 * Yours, franticly,
    Erik

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

 *  Thread Starter [erikstainsby](https://wordpress.org/support/users/erikstainsby/)
 * (@erikstainsby)
 * [12 years, 10 months ago](https://wordpress.org/support/topic/custom-menu-permissions-issues/#post-3929893)
 * As long as I create a submenu item in the top level plugin 9the owner of my new
   menu), the rest behaves as documented.
 *  Moderator [bcworkz](https://wordpress.org/support/users/bcworkz/)
 * (@bcworkz)
 * [12 years, 10 months ago](https://wordpress.org/support/topic/custom-menu-permissions-issues/#post-3929900)
 * I think what may be happening is the submenu callbacks for ‘admin_menu’ are firing
   before the main menu callback fires. I had a similar situation and got very strange
   results. I too pulled what little hair I have out. It took some time to figure
   out what was happening. I was able to combine my add menu page calls so the main
   page must be added first, that may not be a option in your case.
 * You could try hooking the main menu callback with a priority of 1 and the various
   sub menus with a much higher priority number so that they should be called after
   the main menu is already added.

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

The topic ‘Custom menu permissions issues’ is closed to new replies.

 * In: [Hacks](https://wordpress.org/support/forum/plugins-and-hacks/hacks/)
 * 2 replies
 * 2 participants
 * Last reply from: [bcworkz](https://wordpress.org/support/users/bcworkz/)
 * Last activity: [12 years, 10 months ago](https://wordpress.org/support/topic/custom-menu-permissions-issues/#post-3929900)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
