Question

I need help to show the left menu item on other role users dashboard. I am using the code at plugin to add the custom admin menu items .

add_action('admin_menu', 'wp_hotlel_admin_menu');
  function wp_hotlel_admin_menu() {

  add_menu_page('Page Title', 'Menu Title', 10,'unique-slug','ChainForm_page');  

  function ChainForm_page() {
  echo "test";
  } 

The menu is being displayed and working at admin dashboard. But not being displayed at other users dashboard. I am being logged in through Wordpress basic users login section.

I have added the line below,

global $wp_roles;

   $wp_roles->add_cap('Subscriber','wp-wall');

Subscriber is my user type. The menu item is not being displayed still at general users custom menu.

Please help me to fix this.

Thanks in advance.

Was it helpful?

Solution

Your value 10 (the third argument) should be replaced with a capability (e.g. 'edit_pages'). User levels are deprecated. Here is a list of all available capabilities and their associated roles.

OTHER TIPS

The add_cap has been deprecated since version 2.8 I believe. You could use something like:

<?php
if( current_user_can( 'edit-posts' ) ){
  //YOUR CODE HERE
}
?>

See the Codex Pages for Roles and Capabilities:

http://codex.wordpress.org/Roles_and_Capabilities

And a simplified version:

http://web-profile.com.ua/wordpress/dev/user-capabilities/

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top