0

I'm trying to do the OPPOSITE of this...

function my_custom_init() {
    if (current_user_can('administrator')) { 
        remove_post_type_support( 'company', 'editor' );
        remove_post_type_support( 'company', 'excerpt' );
    }
}
add_action( 'init', 'my_custom_init' );

AKA: If current user is NOT 'administrator' then remove the post support.

Daniel
  • 9,491
  • 12
  • 50
  • 66
  • 1
    Possible duplicate of [Check if current user is administrator in wordpress](http://stackoverflow.com/questions/19802492/check-if-current-user-is-administrator-in-wordpress) – m1xolyd1an Feb 27 '16 at 04:42

2 Answers2

2

Just negate the condition with !:

function my_custom_init() {
    if (!current_user_can('administrator')) { 
        remove_post_type_support( 'company', 'editor' );
        remove_post_type_support( 'company', 'excerpt' );
    }
}
add_action( 'init', 'my_custom_init' );
elixenide
  • 44,308
  • 16
  • 74
  • 100
0

Try this using the not operator (!) as in:

function my_custom_init() {
   if (!current_user_can('administrator') { 
       remove_post_type_support( 'company',     'editor' );       
    remove_post_type_support( 'company', 'excerpt' ); 
    }
} 

add_action( 'init', 'my_custom_init' );
beaudetious
  • 2,354
  • 3
  • 36
  • 60