You are going to want to look at a few things. First, the WP_user object which will enable you to check if the user is even logged in. But you can also check capabilities with the has_cap method.
You can even define your own capabilities and apply them to users.
Then you would do something along these lines:
<?php
$user = wp_get_current_user();
if($user->exists()){
// logged in user
if( $user->has_cap('edit_users') ){
// user can edit users
}else{
// this user cannot do that
}
}else{
// anon user
}
Related Posts:
- How to customize wp_signon()
- Allow admins to login as other users
- How to allow an user role to create a new user under a role which lower than his level only?
- Allowing users to edit only their page and nobody else’s
- Disallowing Users of a Custom Role from Deleting or Adding Administrators?
- What the user_status column?
- Hide Admin Menu for Specific User ID who has administrator Role
- Copy a user from one WordPress site to another
- How to remove “Super Admin” from All Users for those that are not a “Super Admin”?
- Can I create users that have access to *some* other users posts instead of all other users posts?
- Set default page for user account in admin
- Hide everything on site for visitors except specific page IDs
- Managing Users and Creating Groups [closed]
- How to disable a specific page for a specific user
- wordpress user roles are not working
- Problem with automatic role change through cron job
- How can I allow an User to publish only 5 posts per month?
- Where are $current_user->allcaps set?
- Can I Create a Second Admin Level User Role?
- Customising “user ids” and add to ‘user’ panel in the admin area
- How to hide some users to unlogged users [closed]
- Redirect admin 403 “Cheatin uh?” admin pages
- Unique password to access a section site
- WordPress user role with create user capability?
- Update user role for expired membership
- Custom User Role: Can Edit Own Page, Cannot Create New
- WordPress install checking permissions of user id 0
- Allowing users to edit only their page and nobody else’s
- How to bulk change user role to “No role for this site”
- Restrict Access to the User Profile
- view and update form only for registered users
- Control Category of each user can post
- Limit user access to installing/configuring a plugin?
- file upload user profile
- MySQL query to list users who never signed in
- Wordpres password as plain text in email
- WordPress password as plain text in email
- How to remove/limit Editor accounts privileges, to prevent them from deleting media and pages created by Admin
- Find out if logged in user is not subscriber
- Whats the best way to share user data across multiple WordPress websites?
- User-edit role setting distinct from wp_capabilities? [closed]
- Problem with Hebrew characters in username
- How to let user set password on registration
- How to display custom user meta from registration in backend?
- Allowing an email as the username?
- How to update user role without logout
- Post list based on the user that is logged in
- Do not allow users to create new posts and pages
- Get user info outside WordPress
- ACF Upload Image in front-end with custom form
- Is there a simple way to manage capabilities per user?
- How Do I Prevent Junk Account Creation?
- Can I bulk register contributors for a new blog
- How do I enable new account notification emails (to the administrator)?
- Users roles, make a page belonging to multiple users
- Redirect after users complete profile form
- Can’t add users in admin after copying database
- Front End Registration Form Code – Password Field Not Saving
- How can I verify users facebook ID that he provides during signup process
- Getting users by specific capability, not role
- Creating user in Firebase after WordPress user registration
- Can i add password field into my wp registration form?
- User capability for editing their own comments
- What are some best practices for user exit strategy?
- Is there a way to identify a user in a custom REST API method? [duplicate]
- wordpress disable login for unverified user
- How to create user specific pages (not user role!)?
- Allow Contributors to Upload Files
- Register user when after filling contact form
- Is possible to allow user to login with different role?
- Limit number of users a role can create
- Keep Logged in Users out of Admin Panel
- How to set custom avatar for users?
- How many people are allowed to use same wordpress account at the same time?
- Restrict access to non-wordpress section of site with user roles?
- How to add registration date and last login date to user list page
- What’s the correct way to add capabilites to user roles?
- Does it matter if the very first user, usually Admin, does not have a user ID of 1?
- Automatic Website user password generation
- List all users and current week entries
- Groups and subgroups for permission
- Remove specific administrator’s capability
- How to create a front facing user sign up, log in and profile pages like FoodGawker.Com [closed]
- Is WordPress secure enough for a multi-user article directory?
- define two login page url
- User with same Mail but a different additional info(like domain)
- User can’t search himself on rest api
- Easily adding multiple existing users to a multisite site
- How to Moderate Edits to User Profiles?
- Create relationships between users or user roles
- User Permissions on custom post type
- Insert user register into my own user table instead of wp own user
- What is the best user experience for user to perform an action using email?
- Registration page as homepage
- throttle/limit a logged in user’s http requests to specific page on a per day basis
- Different role for free and pro users in wordpress without using bbpress
- New User ID not working in custom function with user_register hook
- Limit roles displayed in users.php depending on custom role
- Creating Custom user type just like custom post
- how can i inform other users about new user registration? [closed]