I'm using the function below to load some javascript that removes the checkbox in the User Profile that is used to toggle the Visual Editor:

//Remove Visual Editor option in User Profile
function remove_visual_editor_admin_script( $hook ){
 if ('user-edit.php' != $hook) {
    wp_enqueue_script( 'remove_visual_script', get_stylesheet_directory_uri().'/js/remove-visual-editor.js', array('jquery') );

It loads a simple jQuery function in remove-visual-editor.js that removes the HTML and CSS and hides the checkbox.

Problem is, the Visual Editor checkbox appears on two admin pages: one is user-edit.php and the other is profile.php; I'm calling the jQuery script on user-edit.php above.

So I tried an array of page templates, like this

if (array('user-edit.php', 'profile.php') != $hook) {

with no luck.

How to I add the remove-visual-editor.js to both 'user-edit.phpandprofile.php` pages?

Is there another way to add an array or multiple pages to the if line?

1 Answer 1


Use in_array():

if ( in_array( $hook, [ 'user-edit.php', 'profile.php' ] ) )
    // do something

Or wait for the action personal_options, and enqueue the script for the footer. This action is fired in both cases. See this old example.

  • Thanks! Works great. I didn't know that there was no dedicated hook for user management. Commented Aug 18, 2014 at 3:19
  • Just found out this breaks in the 4.0 Beta. Had to go back to my original function above with no array. Commented Aug 25, 2014 at 4:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.