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!!
Related Posts:
- Editor can create any new user except administrator
- Remove Ability for Other Users to View Administrator in User List?
- Groups of capabilities: users with multiple roles?
- User-edit role setting distinct from wp_capabilities? [closed]
- What’s the difference between the capability remove_users and delete_users?
- How to let contributors to create a new revision(draft) editing their published posts
- Disallowing Users of a Custom Role from Deleting or Adding Administrators?
- How to update user role without logout
- How to check user role without using current_user_can()
- Do not allow users to create new posts and pages
- \WP_User Object | What’s the Difference Between {caps} and {allcaps}?
- How to enable the theme editor cap for an editor role?
- How to assign capabilities to user NOT to User Role
- How-to Delay The Capability To Publish Posts?
- Is there a simple way to manage capabilities per user?
- Prevent Admin user to edit/see super admin from users list
- current user can edit user?
- Get User Role by ID not working
- Getting users by specific capability, not role
- Restricted registrations or removing the ability to edit your password/email
- Are User Levels Still Currently Used?
- Does an AJAX call on the Admin Side Automatically include the User Data/Capabilities?
- Remove Capabilities from WP admin for specific user role
- Add a role and give admin priviledges
- Where are $current_user->allcaps set?
- How can I prevent certain custom roles from seeing other custom roles on the user list page?
- What’s the correct way to add capabilites to user roles?
- Can I Create a Second Admin Level User Role?
- Privilege to recover trashed posts
- Assigning multiple or additional capabilities to specific users or how to create additional roles like bbpress roles?
- how do I add role and capability after I create a new user
- current_user_can() causing critical error
- How to make WordPress ‘editor’ role to list/view/add/edit users only with the role ‘author’?
- Author Error “Sorry, you are not allowed to access this page.”
- fine-grained capabilities for user related capabilities
- Disabling user capability to edit_posts or delete_posts in the front-end
- Groups roles & capabilities
- Subscriber role – blank page
- No one can edit post/pages by Administrator
- current_user_can() returning true for capability when the user and role do not have the capability
- Getting a List of Currently Available Roles on a WordPress Site?
- Confirmation required on email change
- get_current_user_id() returns 0?
- Upload gravatar in WP profile?
- How to stop a user from updating the post date
- Recover the user that have been deleted
- determining if the user is logged in
- How to check that if current user (ID) has posts or not
- how to get recent registered author id?
- set_role has no effect
- Get users only if Gravatar is specified
- Authenticate with a Rails app?
- Send Email to Users after Deleting Account
- *wpupdateuser* user_login in my WordPress database
- Updating user meta
- Changing a username
- Delete users from multisite after they have not logged in for a set amount of time?
- Where is the information about the authors for articles stored?
- Restrict access of admin uploads to certain logged-in users?
- Find user by nicename and open profile
- Using Cloudflare caching on wordpress with front-end user logins
- Redirect user after successful email change
- Reset Password policy
- Which function is called after update any field of user from any where of the site
- Custom Comment Notifications Fire on each Page Load
- The Simple and Correct Way to Add User Meta
- Export Users and their Advanced Custom Fields
- Hide hour from displaying when using user_registered
- How to copy user_nicename value into user_login
- Send clear password via mail
- Check if user is logged in via JS? [duplicate]
- Adding fields to the “Add New User” but the form data not saved into DB
- Admin approval for editing user profile
- Using a custom field value as current users name [closed]
- WP Create User – Preventing repeated information
- Editor role can only create/edit/delete users who have one of two roles
- Can’t add user- wrong message “this user name is invalid because it uses illegal characters”
- WordPress 5.8 – Hide or Remove personal fields from admin Profile page
- Restricting wordpress login sessions for a web app
- change user password REST API
- Find count of WordPress users by role and search string for user name
- Append USER ID to an outbound link?
- How to destroy all user sessions via WP-CLI
- Is a list of user names or IDs in a custom profile field the best way to create a followers list?
- Get meta key with value for user
- Redirect current user
- Display Users and user url’s
- custom login form, guide me
- Get the author registration date in the header.php file
- Front end login and page restriction
- How i will get the images of highest scored users?
- i need to let a user to add a role from a frontend form
- Integrating Facebook Registration (and Login) on a WordPress page
- WordPress C# User Login
- Create users from frontend without password
- How to get user contact info
- Why does a super admin on multi site get a rest_user_invalid_id error code when requesting user details through REST?
- determine active user browser at the same time
- get Discussion setting in wordpress
- Set a minimal number for next user_id