You don’t need to store anything, just check the current logged in user via user_can
:
global $current_user;
get_currentuserinfo();
if ( user_can( $current_user, "role_apple" ) ){
// do something
}
Related Posts:
- 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)
- Add Custom User Capabilities Before or After the Custom User Role has Been Added?
- How to Change the Entire WordPress Admin panel Look and Feel?
- How to Structure a New Role/Capability Scheme?
- How to add more than 1 user role to sub-menu pages
- How to allow Unfiltered HTML in a wordpress multisite install
- 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
- query users by role
- Hide plugin dashboard menu item for specific roles
- get_posts() not working when accessing with a custom user role
- Limit role to one plugin [duplicate]
- 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
- Hide custom post type by user roles
- Menu page with minimum capability as ‘Subscriber’ doesn’t allow ‘Admin’ to access it?
- How can I change my assigned user role in WordPress 3.5.1?
- How to determine which capability to use?
- Allow contributor user role to perform copy operation PHP
- Enable a role named ‘backend_user’ to access my plugin pages
- Add custom parameter for custom user role
- Buddy Press restrict the capability to edit users
- How I can give access to my custom plugin for editor roles user?
- 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
- 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
- Remove default wordpress roles
- How can I add an option to the Page Template list from a Plugin?
- Using composer for dependency management in plugindevelopment
- What is nonce and how to use it with Ajax in WordPress? [duplicate]
- Why does do_action pass a blank string as the first parameter if no $arg is set?
- Build path for a custom portfolio plugin
- add_filter and remove_filter added before and after wp_query
- What is the difference between strip_tags and wp_filter_nohtml_kses?
- How can I hook into existing WordPress Bulk actions?
- Scheduled event does not run at midnight
- creating elements/innerblocks via rangecontrol
- How to check if current static page is frontpage from admin plugin
- Woocommerce add custom button to backend order table
- Earliest WP Hook to Safely and Reliably Redirect
- What is rich_editing?
- How Can I setup WP CLI on Windows development machine running AMPPS?
- What method to use to call a REST API?
- Is it possible to delay execution of shortcode output callback?
- Why my database table not created on activation?
- wp_enqueue_script + wp_enqueue_style Since When
- Resizing Images for a Gallery-Plugin?
- Which themes do you use to test compatibilities with your plugin [closed]
- How to debug a unit test for a WordPress plugin, which uses wordpress-test?
- Is there any way to allow a plugin to write over a previous version?
- How do i validate data entered in a meta box so that only floats can be entered in a field?
- Adding functions to hooks from within a class
- Modify users.php page to create page/post on button clicked
- What filters to call to modify the output of the entire page?
- get_current_screen() return null
- Tried in different ways but sidebar not working?
- How to Create a Simple Related Posts Plugin
- How to run a function on plugin’s options page?
- What stylesheets are available in core?
- Help With Rewrite_Rules For a Custom Plug-In
- Theme Install using a Custom Repository
- Activate User in Code (BuddyPress+bbpress)
- error ‘The package could not be installed. No valid plugins were found.’
- Search: how to extend the existing search to include a custom table
- Plugin development: delete options when updating to a new version
- Custom code for WordPress dynamic menu
- Can’t change the style of a submit input type? [closed]
- How to get all queries’s results after they have executed?
- why update option is not working?
- Special Formatting for WordPress Plugin Description?
- custom wp_editor does not save the content in plugin settings
- How Can I Add Code To A Preexisting Function Without Editing it
- Change the behaviour of a button
- Login page too many redirects
- escape html in jQuery for WordPress
- Progress bar in plugin within admin
- Jquery php request is returning a weird result
- WordPress admin panel not working
- Load script on frontend from widget plugin
- Can’t get wpColorPicker to work in a widget
- Ajax functionality not being called under wordpress plugin
- Add a description/hint field in the admin page of a plugin
- Saving multiple fields as array
- Serialized Data
- Can’t add images in wordpress to my page – button isn’t clickable
- Gutenberg and custom blocks messed up pagespeed score. What did I wrong?
- Gutenberg text field validation
- I don’t understand how symlinks in plugin work
- Undo operation not working in Rich text [Gutenberg]
- WooCommerce adds a newline symbol (\n) between email recipients
- Why isn’t custom sidebar panel not showing up in the Gutenberg Editor?
- Ninja Forms: Front-End Forms, Post ID?