• Resolved Robin

    (@robinperso)


    Hi,

    I want to hide the “leaflet-shortcode-helper” menu for non-admin users.

    I tried in functions.php :

    
    function my_remove_menu_items() {
    if ( !current_user_can( 'administrator' ) ) : // IF NON ADMIN USER
    remove_menu_page( 'leaflet-map' ); 
    // or 
    remove_menu_page( 'leaflet-shortcode-helper' );
    endif;
    }
    add_action( 'admin_menu', 'my_remove_menu_items' );
    

    but it doesn’t work…

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Contributor hupe13

    (@hupe13)

    Try with high priority:

    function my_remove_menu_items() {
    if ( !current_user_can( 'administrator' ) ) : // IF NON ADMIN USER
    remove_menu_page( 'leaflet-shortcode-helper' );
    endif;
    }
    add_action( 'admin_menu', 'my_remove_menu_items' ,999);
    Thread Starter Robin

    (@robinperso)

    thank you ! it works !

    • This reply was modified 3 years, 1 month ago by Robin.
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘How to Hide Leaflet Map in Menu for non-admin users ?’ is closed to new replies.