php - remove_menu_page() not getting initialized within if condition -


I am trying to delete some menu pages based on the user role, but when I if condition < / Code> It does nothing.

  function contributor_posts_action () {if ($ role == 'contributor_posts') {// contributor_posts - custom role // resonance 'here'; For purposes of testing and testing, it therefore goes under the condition of adding condition ('admin_menu', 'remove_menus_contrib'); Function remove_menus_contrib () {remove_menu_page ('edit-comments.php'); Remove_menu_page ('tools.php'); Remove_menu_page ('edit.php? Post_type = directory'); Remove_menu_page ('edit.php? Post_type = city'); } // This function does not get associated with the add_action ('admin_bar_menu', 'remove_admin_bar_items', 999); Function remove_admin_bar_items ($ wp_admin_bar) {$ wp_admin_bar- & gt; Remove_node ('new-directory'); $ Wp_admin_bar- & gt; Remove_node ('new-city'); } // It works properly This is to delete for admin bar}} Add_action ('admin_init', 'contributor_posts_action');    

remove_menus_contrib () and drag the Add_action (' Admin_menu ',' remove_menus_contrib ') Hook function out of your contributor_posts_action () function.

Some Wordpress hooks other (custom) functions.


Comments

Popular posts from this blog

java - Can't add JTree to JPanel of a JInternalFrame -

javascript - data.match(var) not working it seems -

javascript - How can I pause a jQuery .each() loop, while waiting for user input? -