as @Tonydjukic mentioned, the best way is get user role first and then showing content to him.
also with this code we can do it :
$user = wp_get_current_user();
$allowed_roles = array( 'administrator', 'customer' );
if ( array_intersect( $allowed_roles, $user->roles ) ) {
}
Related Posts:
- Add Custom User Capabilities Before or After the Custom User Role has Been Added?
- How can I change my assigned user role in WordPress 3.5.1?
- what’s the meaning of the field wp_capabilities in table wp_usermeta
- Send user activation email when programmatically creating user
- Change default admin page for specific role(s)
- How to check username/password without signing in the user
- How to Change the Entire WordPress Admin panel Look and Feel?
- WordPress REST API call generates nonce twice on every call
- How to Structure a New Role/Capability Scheme?
- How to add more than 1 user role to sub-menu pages
- Custom user profile, registration, login page with theme
- How to use WP default post list tables in a plugin?
- How to allow Unfiltered HTML in a wordpress multisite install
- How to add quick edit and bulk edit fields to users admin section
- How to restrict plugin’s sub-menu pages to admin/subscribers?
- How to not let a user with a new role edit users that have administrator role?
- Execute plugin for specific user role(s) only
- Generating User(s) with Settings API
- WordPress admin deleted user details not removed in database. How to delete WordPress Users from Database
- Print WordPress username id inside JavaScript
- query users by role
- Function Get User Object By Username?
- Check if someone is editing a post (this content is currently locked)
- Hide plugin dashboard menu item for specific roles
- Modify users.php page to create page/post on button clicked
- Subscribe to author?
- How to filter users list on user_status field with get_users()
- Frontend language per user
- get_posts() not working when accessing with a custom user role
- Limit role to one plugin [duplicate]
- Display custom fields in frontside user profile
- Logout users upon login, based on caps/role?
- Set different custom menu items for different user roles
- Prevent third party plugin’s admin page access based on user type
- wp_dropdown_roles() to replace option value = code
- global $current_user not current user
- Display list of uploaded images, filtered by user under a specific user group
- What is the proper way to get logged in user id in a plugin?
- How to build a fool proof AdSense revenue sharing model?
- How do I have now a duplicated user entry if this is not allowed (and I cannot replicate it)?
- How to allow only two (or more) users access to a plugin
- First and last name fields not filled when using wp_insert_user
- Wp-admin Custom User Management
- Check user’s role and store in variable
- Menu page with minimum capability as ‘Subscriber’ doesn’t allow ‘Admin’ to access it?
- get author of published post
- How to get custom post_author?
- Associate multiple email addresses with the same user account, so they can log in with either
- Add User Role: Pre-saved in User-Meta [SOLVED]
- Update a user profile via frontend
- Best practice for Designing a Plugin with this scenario
- Adding another field to user table
- how to get the top 10 popular blogs
- How to relate the Category to user?
- How to determine which capability to use?
- Adding a dropdown on the user admin
- Allowing duplicating users with same user_login and user_email
- Allow contributor user role to perform copy operation PHP
- Why User_login key doesn’t work with wp_update_user()
- How to grab data after wp user search is complete
- Enable a role named ‘backend_user’ to access my plugin pages
- Add custom parameter for custom user role
- How to prevent users from deleting their accounts?
- Buddy Press restrict the capability to edit users
- User Registration Moderate
- How I can give access to my custom plugin for editor roles user?
- How to retrieve custom profile fields associated with different users
- Remove all capabilities in separate method fails versus included in method
- Remove from a div by class name from post page if post author role is not administrator
- Upgrade routine: Interaction with user confirmation
- Adding admin for specific users
- What is more secure checking capabilities of user or checking role of user in WordPress plugin development
- New Users are saved with no role selected
- WordPress User Management Departmental Managers
- Multiple Users Logged In Causing Incorrect Account Returned
- first_name property missing inside register_user action hook
- user can login from single account detail from multiple locations(computer) at the same time [closed]
- Create Unique and Customized User ID for Website Members in WordPress
- Remove default wordpress roles
- How to lock users account until approvation
- How are bulk actions handled in custom list table classes?
- Creating Settings Page with dropdowns for Plugin
- Empty POST data on server on AJAX request using Angular $http
- Implementing namespaces in plugin template
- Commit changes to WordPress Plugin SVN with TortoiseSVN
- add_shortcode is not working [duplicate]
- How can I add a simple custom field to my plugin?
- Inserted double quote when prepending to the_content
- unable to wp_enqueue_script(‘suggest’);
- Run uninstall.php if a checkbox is checked from settings page
- Gravity Forms Anchor only on Front Page?
- Multiple page plugin settings
- Do I lose translations when I change my Text domain for my plugin on wp.org?
- Override woocommerce loop-start.php from theme using plugin?
- Relational / Associate tables using native WordPress functionality
- Pull commentdata for pre_comment_on_post from comment_post_ID
- How to Rewrite WordPress URL for a Plugin
- Reading the inside of
- WordPress, GIT, Renamed Plugin Dir + files – Working Code now Broken [closed]
- Reinitiate Gutenburg’s blocks using javascript