0

I am using wordpress 4.2.3 and jetpack latest version. All users of my site are contributors. I want to hide jetpack from contributors. I hide the jetpack menu from dashboard by WP admin UI customize plugin. But when any user type url: mysite/wp-admin/admin.php?page=jetpack it is appearing on browser.I used this code,but not helped me.

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 );
Escape me !!

0

Use the code given below, In this code we are checking if page is 'jetpack' and based on that showing custom error message.

add_action( 'admin_init', 'restrict_page' );
function restrict_page() {
    if ( class_exists( 'Jetpack' ) && !current_user_can( 'manage_options' ) ) {
        if ( isset( $_GET['page'] ) && $_GET['page'] == 'jetpack' ) {
            wp_die( 'no access' );
        }
    }
}

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.