0

I have this complex scenario:

1) I'll have multiple admin users.

2) Only one admin can 'see_encrypted_pass'

Now, I want to assign custom 'see_encrypted_pass' capability to only one admin (say, John). I have a restricted page containing encrypted password. I want to use this on that page-

if(current_user_can('see_encrypted_pass')){
    //show encrypted password
}

How do I do that?

1

I solved it myself :) I just added custom capability to the user-

$user = new WP_User(1); //1 is the admin ID
$user->add_cap( 'see_encrypted_pass' );

Then checked-

if(current_user_can('see_encrypted_pass')){
    //encrypted password
}

It works!!

  • Remember to come back and accept your own answer after the restriction is lifted :-) – Pieter Goosen Jan 27 '15 at 6:23

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.