0
votes

I have create a new user role.

add_role('lln_assessor', 'LLN Assessor', array(
'read' => true, 
));

this role will access a custom admin menu page .

add_action( 'admin_init', 'my_remove_menu_pages' );
function my_remove_menu_pages() {

    global $user_ID;

    if ( current_user_can( 'lln_assessor' ) ) {
        add_menu_page('Axcelerate LLN','LLN Datas','read_assess_lln', 'Axcelerate_Link_Admin_lln_data','axcelerate_link_admin_lln_data_fn','','1.0' );
    }
}

but first I must create a custom capability for it.

$role_object = get_role( 'lln_assessor' );

// add $cap capability to this role object
$role_object->add_cap( 'read_assess_lln');

but the issue when I try to access the 'LLN Datas' menu in the admin dashboard I got this error.

You do not have sufficient permissions to access this page.

I think the error was on the custom capability but I have no idea on how to fix it. please help.

1

1 Answers

0
votes

Try changing the current_user_can from lln_assessor to read_assess_lln

if ( current_user_can( 'read_assess_lln' ) ) {
        add_menu_page('Axcelerate LLN','LLN Datas','read_assess_lln', 'Axcelerate_Link_Admin_lln_data','axcelerate_link_admin_lln_data_fn','','1.0' );
    }

And make sure you are logged in as lln_assessor instead of admin.