• Hi there,

    I am trying to hide these menu items for only but a few specified admin users:

    I’ve tried fiddling around with remove_menu_page() and remove_submenu_page() in my theme’s functions.php but neither method seems to work.

    
    function CustomDashboard_menus () {
       // if userID isn't 2 and 438, hide these menu items
        $allowed_ids = array(2,438);
        if(!in_array(get_current_user_id(), $allowed_ids)) {
        
          // PARTICIPANTS DATABASE
          // remove_menu_page( 'participants-database' );
            // List Participants
            // Add Participant
            // Manage Database Fields
              remove_menu_page( 'participants-database-manage_fields' );
            // Manage List Columns
              remove_menu_page( 'participants-database-manage_list_columns' );
            // Import CSV File
              remove_menu_page( 'participants-database-upload_csv' );
            // Settings
              remove_menu_page( 'participants-database_settings_page' );
            // Setup Guide
              remove_menu_page( 'participants-database-setup_guide' );
        }
    }
    add_action( 'admin_menu', 'CustomDashboard_menus', 999 );`
    
    • This topic was modified 2 years, 10 months ago by Trippetchz.
    • This topic was modified 2 years, 10 months ago by Trippetchz.
Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author xnau webdesign

    (@xnau)

    Yes, you probably won’t be able to do it like that, the timing has to be just right.

    Have you tried giving those users a custom role? that is the easiest way to control access. Once you have your custom roles set up, you can select the custom role in the Plugin settings under the Admin tab. There is a secondary plugin role (Record Editor) you can use to give people limited access to plugin menu items and functionality.

    The plugin does have filters built into it to control who has access to various menu items if you want to to it with custom code.

    Thread Starter Trippetchz

    (@trippetchz)

    Hi there,

    Thanks for getting back.

    Yes, I’d prefer the latter as I’d like to check using an array of WordPress User IDs as opposed to custom roles, etc.

    Which filters can I use, since the common method above isn’t working?

    Thanks,
    T

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Hiding menu items’ is closed to new replies.