Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I'm adding an extra menu item in admin menu by using add_menu_page.

add_menu_page('Calendar', 'Calendar', 'edit_posts', 'wp-eventcal/eventcal-manager.php');

Still my editors do not see the menu item. Why not? Any user that can edit a post, should now be able to see the menu item.

Update

This is the code:

  // Define some constants
  define('WP_CAL_PLUGIN_DIR', trailingslashit( str_replace("\\","/", dirname(__FILE__) ) ) );
  define('WP_CAL_PLUGIN_URL', trailingslashit( str_replace("\\","/", dirname(__FILE__) ) ) );


  // Plugin activation / deactivation script
  register_activation_hook(__FILE__,'event_cal_install');

  // create custom plugin settings menu
  if ( function_exists('add_action') ) {
    add_action('admin_menu', 'event_cal_menu');
    add_shortcode('eventcal', 'shortcode_display_event');
  }

function event_cal_menu() {
    //create new top-level menu
    add_menu_page('Calendar', 'Calendar', 'read', 'wp-eventcal/eventcal-manager.php');
}

Could it be admin_init in add_action that gives me problems?

Update 2
If I log in as administrator, I can see the menu item.

share|improve this question
    
I'm not sure if this is what's causing the menu item not to show up (I don't think it would), but you should also have a callback as a 5th parameter at the end, so that there's some output to the page on that admin menu. The only other thing I can think of that would prevent the menu from showing up is too early or too late registration. Can you post your surrounding code (e.g. how you hook in to add the menu page, etc.). Also, can other roles that have edit_posts see the menu? –  John P Bloch Jan 18 '11 at 14:36
    
@John P Bloch: done –  Steven Jan 18 '11 at 15:23

1 Answer 1

up vote 0 down vote accepted

Must be a problem with the surrounding code, your add_menu_page code works fine inside my test code, i can see the item as an admin or editor.

add_action( 'admin_menu' , 'admin_menu_new_items' );
function admin_menu_new_items() {
    add_menu_page('Calendar', 'Calendar', 'edit_posts', 'wp-eventcal/eventcal-manager.php');
}

Works just fine for me..

Are you using any plugins for managing the admin menu, such as Adminize? Or alternatively using any CSS to hide elements in the menu? Only two reasons i could think it would be hidden(aside from a problem with surrounding code).

share|improve this answer
    
I'm not using any plugins for managing admin menu, nor any CSS to hide elements in admin. If I use administrator in stead of read, I can see it as administrator - but not as a user without admin rights. –  Steven Jan 18 '11 at 16:39
1  
OK, I just found the error. A bit embarrassing really. I was using .com in my URL which is my prod server - I was supposed to use .no which is my localhost. So... problem solved - it works now :) –  Steven Jan 18 '11 at 16:46
    
I'm sure we've all done similar things(i know i have numerous times), at least you took the time to post back and let us know, so happy to hear you solved your problem... ;) –  t31os Jan 18 '11 at 16:57

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.