mercredi 2 décembre 2015

Creating Custom user role to access a custom plugin

I have created a custom plugin that can access in the backend by a custom user role.

first I create a custom role:

add_role('lln_assessor', 'LLN Assessor', array(     
'read' => true, // true allows this capability
'assess_lln' => true, // Allows user to edit their own posts
));

then the menu page of the plugin.

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','assess_lln', 'Axcelerate_Link_Admin_lln_data','axcelerate_link_admin_lln_data_fn');
    }
}

function axcelerate_link_admin_lln_data_fn(){
        include_once('axcelerate-link-admin-lln-data.php');
}

Now, when I tried to access the dashboard of the user role and click the LLN Datas menu I got this error:

You do not have sufficient permissions to access this page.

my question is how can I access this page menu? I dont want to plan that the lln_assessor will be a administrator role because I want only to access this admin page of LLN Datas.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire