0

i´am developing my own WP plugin with custom functions and i would like to show the new submenu in the standard admin panel for everyone, who logs in. My code:

$capa = 'administrator' or 'author' or 'visitor';
$this->pagehook = $page =  add_menu_page(__('Myplugin','my_plugin'), __('Myplugin','my_plugin'),$capa, $this->page_id, array($this,'render') )

As you can see, i defined 1 variable $capa, what can be one of the three strings. My problem is that the plugin is visible only when i´m logged in as admin. When I log in as visitor or author, the plugin is not visible.

Can u help me?

1

$capa is a PHP expression and will always evaluate to administrator. Use the capability read instead - every role (by default) has this.

|improve this answer|||||
  • I would add that only capabilities, and not user roles, should be passed to add_menu_page. – cybmeta Apr 10 '15 at 15:48
  • Thanks for advice. I changed my $capa to read, but there is no change in settings panel. Only admin can see the plugin... – steven967 Apr 10 '15 at 15:55
  • Are you defining custom roles/capabilities? – TheDeadMedic Apr 10 '15 at 15:56
  • Sorry guys, i forgot to comment one condition before my code. Everything is working now. Thanks again. – steven967 Apr 10 '15 at 15:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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