Reputation: 1
I current have this code written:
add_action( 'init', 'hide_user_caps' );
function hide_user_caps() {
$user_id = 1;
$user = new WP_User( $user_id );
$user->remove_cap( 'edit_posts' );
}
However, this doesn't seem to be doing anything. Any ideas?
Thank you
Upvotes: 0
Views: 331
Reputation: 2020
If you want to specifically deny a capability from a user (not a role), you need to use the add_cap()
[1] method and specify that the $grant
parameter is false. [2].
$user_id = 1;
$user = new WP_User( $user_id );
$user->add_cap( 'edit_posts', false );
WP_User::add_cap()
Upvotes: 0