skip to Main Content

I need to remove the Premmerce plugin menu item from the admin menu (leaving it visible only to the admin and hidden for all other roles).

I had the same problem with the JetPack menu item which I fixed by adding this code to the functions.php file:

function ap_remove_jetpack_page( ) {
    if ( class_exists( 'Jetpack' ) && !current_user_can( 'manage_options' ) ) {
        remove_menu_page( 'jetpack' );
    }
}
add_action( 'admin_menu', 'ap_remove_jetpack_page', 999 );

I would like to do the same for the Premmerce menu item. How can I do?

Thankyou

2

Answers


  1. If you are using the main premmerce plugin then you can use following code.

    function remove_premmerce_menu_item() {
        // Check if Premmerce plugin is active
        if ( is_plugin_active( 'premmerce/premmerce.php' ) && ! current_user_can( 'manage_options' ) ) {
            remove_menu_page( 'premmerce' );
        }
    }
    add_action( 'admin_menu', 'remove_premmerce_menu_item', 999 );
    
    Login or Signup to reply.
  2. Actually you don’t need to check this statement

     class_exists( 'Jetpack' )
    

    current_user_can is enough.

    What you need is to know the slug this can be done by following those steps from the extension search page

    1. Click on more details
      enter image description here
    2. Click on WordPress.org extension page
      enter image description here
    3. The slug is in the URL
      enter image description here

    You can test with other plugins to verify if the behaviour is still correct.

    Sources

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search