Paul French
Paul French

Reputation: 23

PHP - What's opposite to current_user_can?

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.

Upvotes: 0

Views: 956

Answers (2)

elixenide
elixenide

Reputation: 44833

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' );

Upvotes: 2

beaudetious
beaudetious

Reputation: 2416

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' );

Upvotes: 0

Related Questions