To show content only for users with role ‘agent’, try to use this snippet:
<?php if ( ( $user = wp_get_current_user() ) && in_array( 'agent', $user->roles ) ) { ?>
///here the content
<?php } ?>
If you want to block users by ID, check the following snippet:
<?php if ( ( $user = wp_get_current_user() ) && in_array( 'agent', $user->roles ) && in_array( $user->ID, array( 8, 9 ) ) ) { ?>
///here the content
<?php } ?>
Related Posts:
- This CSS Stuffing Works, But Is This A Good Practice?
- Settings API – easiest way of validating checkboxes?
- WordPress Admin back-end – advanced options page?
- How To View Site from Non-Logged-In User’s Perspective
- wp_dropdown_pages() in theme admin page
- Settings API not saving values to database
- Admin option sidebar count
- Problem with Settings API: changes are not saved after submit
- Add Custom Script in Other Plugin’s Options page
- Accessing variable from admin panel?
- How can I POST or GET to the same admin page from which I am POST-ing or GET-ing
- WordPress custom admin functions security
- Show global Message in User Profiles with admin only Input field in WordPress Backend
- [Multisite]How can I update custom blog option?
- Call require_once form admin page with checkbox
- Get Link of Page Selected through a Select Field in Custom Admin Page
- My code for creating an admin option doesn’t work
- I don’t have permission to save the theme options I created myself?
- Pull Random Images From Options Page [closed]
- Woo Commerce Settings for Check-out Form [closed]
- Where in WP can I check history or log of updates of plugins etc?
- How does admin-ajax.php work?
- Hide other users’ posts in admin panel
- Editor Styles and Typekit
- WordPress admin stylesheet
- Is it possible to create a WordPress tour? V3.3.1
- Can an admin check passwords of registered users?
- Prevent author from changing their posts if admin has modified
- Showing WP_Error message with admin_notice action hook
- Can I set a default dashboard layout for all users?
- Taxonomy/category hierarchy lost when editing posts [closed]
- How to remove “Super Admin” from All Users for those that are not a “Super Admin”?
- Customize the upload screen
- How to print the output of the get_num_queries function from frontend to backend?
- Javascript not working in admin
- Setting Login with User Name and Password default option for Jetpack Admin Login
- add_submenu_page set for multiple roles [duplicate]
- Adminstering Large Number of WordPress Sites
- Admin: global $post empty
- How to remove “publish metabox” from each post type
- Change home-url in dashboard
- Admin doesn’t have sufficient permissions to plugin’s page
- How to restrict the editors from viewing/editing pages created by admin?
- Admin multiple column sorting
- How do I add a contact form?
- Unable to login, old site with previous developer gone
- How to default display name to first name and last and disable the profile field
- Adding html format on tinymce visual editor
- Hide one admin from another admin
- Using shared SSL for login/admin
- Get a listing of portfolio items and categories
- Edit Custom Post Type on Custom Admin Page instead Post Admin
- WordPress Remove Submenus
- Continuous Login Sessions For Super Admins Across Multi-Site Network of Sites
- using rewrites to secure login page
- page not updating with database
- Client system for media review?
- Redirect from the dashboard to edit.php if wp_is_mobile() is true
- Seems that admin_post_{action} does not executing
- WordPress 3.1’s admin bar disappears only leaving its 28 px padding (in ubuntu)!
- How to log out from admin or front-end only?
- Shared account / dual blogging in WordPress
- WordPress Brute Force Prevention
- How To Make Iris Color Picker Showed Up Over Form and Text?
- admin_enqueue_scripts not rending JS file correctly
- my checkbox is not saving it’s value
- Can’t login to my admin area
- how to show admin notice in custom menu page after submitting the form?
- Accidentally changed website url
- Private post hidden from Admin too
- Send admin to a different login than users?
- How to change the descriptive text on the menus admin page?
- Having problem creating local instance of wordpress site
- WordPress Plugin Admin Tab
- Gutenberg UI has changed
- How To Remove Import/Export Option From Tools?
- Unable to access admin web page
- Error “Sorry, you are not allowed to access this page”
- Create WordPress Menu Item Without Linking to a Custom Page
- Search Only Works when Logged into Admin
- exclude ID on avatar
- Missing content on website. Admins cant sign in
- Different role for free and pro users in wordpress without using bbpress
- Is Post-Form Resubmission somehow prevented in WordPress 4.2.2?
- WordPress login not working
- Enqueue script throws error in console
- How to sort post_meta in edit.php?
- Scripts are not called until I login from wordpress backend
- Link to all posts page?
- WP Logs me out after updating anything on dashboard
- Calculate and save an average in a meta
- If the only thing I use MySQL for is WordPress, do I need MySQL’s timezone tables?
- plugin to upload to youtube via wordpress [closed]
- My Account Lost Administrator permission
- WordPress admin panel is blank
- deploying a standard build of wordpress in WHM/cPanel
- 2FA for admin login only, is it doable?
- Add a user to edit the layout of a site
- CSS Styles specific to Admin Sidebar not loading
- Display notice in block editor after wp_insert_post_data hook