• Hi,

    I am developing a plugin, in that plugin, based on user selection the plugin should display the plugin mmenus or options to all users or restricted users.

    I tried by using for administrator only
    add_menu_page('id', 'name', 'administrator', basename(__FILE__), 'call_back');
    worked fine and I tried changed administrator to read, edit_posts, worked perfectly.

    But when I tried to get the user input using get_option and based on the get_option the capability will vary, for example user selected the plugin menu should display to all users including subscribers. It should be
    add_menu_page('id', 'name', 'read', basename(__FILE__), 'call_back');

    So I tried like this,
    0 – Administrator
    1 – edit posts
    2 – read

    First I get the user value using get_option() and based on the option I tried,

    If($value==0)
    $valueee=administrator;
    elseif($value==1)
    $valueee=edit_posts;
    elseif($value==2)
    $valueee=read;
    add_menu_page('id', 'name', '$valueee', basename(__FILE__), 'call_back');

    After using like this it is not working 🙁

    Kindly suggest me

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)

The topic ‘Hide/Show Plugin Menu options to Role based’ is closed to new replies.