0

I have used hook_permission to limit user for some places and to created a permission rule. However, I have not combine two permission from another modules for my custom module.

I'm working on a module that would allow user to used the Administration Menu when user are on a Desktop and used the Mobile Friendly Navigation Toolbar when the user is on a mobile.

I'm using the hook_page_build to hide the css from mobile or desktop display.

So now I'm trying to limited the hook_page_build to user that only have access to the Administration Menu and the Mobile Friendly Navigation Toolbar.

To be more specific here is the permission that I want user to have enable before this module is been load.

Access administration menu

enter image description here

And the another permission that user need to have is Use the administration navbar.

enter image description here

Once these two permission have been granted the my custom module is going to be able load. How can I do this ?

0

I found the solution here is how is done....

function my_custom_module_page_build(&$page) {

    // Check if user have access to the administration menu
    if (!user_access('access administration menu')) return false;

    // Check if user have access to navbar.
    if (!user_access('access navbar')) return false;

     drupal_add_css(drupal_get_path('module', 'my_custom_module') . '/css/mobile.css');

}

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.