Megha Paul
Megha Paul

Reputation: 385

how to give access to a perticular plugin page to a specific role based user in admin panel?

i have developed a plugin where i have to give access to a specific role base user but i can not do that

add_action('admin_menu','pro_admin_menu_gallery');
function pro_admin_menu_gallery() { 
    add_menu_page(
        "Work Request",
        "Work Request",
        8,
        "work-request",
        "pro_admin_menu_list",
        get_site_url()."/wp-admin/images/generic.png"
    ); 
    add_submenu_page(
        'details',
        'Work Request',
        'Work Request',
        '8',
        'details',
        'pro_admin_list_site_gallery'
    );
}

i have tried this code but where i have to modify this ?

Upvotes: 0

Views: 56

Answers (1)

diggy
diggy

Reputation: 6828

User levels have been deprecated since WP 3.0. You'll have to replace 8 in your code with a capability that is associated with the user role that should have access to your plugin's admin pages. E.g. for admin users, you'd use manage_options.

More info: http://codex.wordpress.org/Roles_and_Capabilities

Upvotes: 1

Related Questions