If I understand you correctly, you want to determine if the user has any role that is in some pre-defined list like this:
$accepted_roles = array(
'administrator',
'editor',
);
if ( ! empty( array_intersect( $accepted_roles, $user->roles ) ) ) {
...
Related Posts:
- count() parameter must be an array or an object that implements countable in laravel
- Receiving Stripe Webhooks on a wordpress website
- Sorting list of sites from multisite network using wp_get_sites
- Remove Customize Background and Header from Appearance admin menu without CSS or JS
- PHP XMLRPC for WordPress: Adding meta tags and description
- How do I get the author’s page url from their ID?
- probleme adding Txt and Links in preg_match()
- Correct use of curly braces vs alternative synax
- the_author_meta not working
- Missing Author Information
- How can I set custom order use this function
- Configuring WP-CLI on Windows 10
- Assign a picture URL to a page via PHP
- Check if Product is in a Specific Category in Functions.php
- How to generate HMAC-SHA1 signature to use with WP REST API and OAuth1
- Adding ads code between comments
- How to send user data in json format to another server when user register on wordpress site in PHP
- How to create and work with custom data / tables (i.e., for arbitrary data)?
- Limiting woocommerce line_total decimal length
- Fetch posts from category in custom page template
- How do you use WP slugs for PDF files / media?
- Nesting if statements to echo only one string based on what tag was filtered?
- How to properly loop through these external URLs to get them into the sitemap using this hook
- only show container with next/prev links if they exist?
- JS file work only in index page
- If no products are on sale – hide ID or class
- Custom shortcode outputs plain text instead of HTML at top of post
- How to get the value of input hidden html from text editor to custom page template?
- Gravity form built in Captcha
- Autocomplete search box
- Fetching instagram api not working on wordpress
- add_theme_page to add_menu_page theme options convert
- WordPress Scripts Being Loaded in Footer
- Jquery function working in Dev Console but not otherwise [duplicate]
- Headers already sent in Pluggable.php / homepage and wp-login error
- Unique session WordPress
- Get posts from multiple post type
- How to convert select to HTML with PHP tags inside of it [closed]
- get the correct url for an folder in wp-includes wordpress
- Can i put my shortcode inside a variable in php files?
- Replace Woocommerce “add to cart” to be “Download” button [closed]
- JS value to PHP variable to change div background color with PHP If else statement
- How to fix “Object of class WP_Term could not be converted to string”?
- Started getting warning message following host’s PHP upgrade
- Store post content in a php variable and output them using for loop
- Running rmdir function on post save
- Only show image from custom field when present
- Upload multiple files in randomly generated folder using wp_upload_bits
- Loading two post layouts for the same post with different url
- How do I populate custom field with current user role in Woocommerce [closed]
- Parse error: syntax error, unexpected ‘}’ [closed]
- Personalize checkout text
- When echo follow Ajax button inside Ajax pagination template not working?
- jQuery Ajax PHP function call returning [object Object]
- Add category to post meta
- Nginx WordPress and another Web app URL structure
- Can I remove or edit an include() from a function with a filter?
- Creating customized php files in theme folder
- WordPress time queries
- How to put search bar & logo in the “primary navigation” storefront theme?
- I want to include a particular word into the excerpt of every posts of a custom post type. How can I do that pragmatically?
- Disclaimer that will show every refresh of the page
- Providin exception to WordPress wp_nav_menu Custom CSS Classes
- Send an e-mail on address with the link with disliked post
- List sub categories and corresponding posts of a parent category
- Woocommerce My acount page
- IF statement not working – Any suggestions?
- Child theme overirde template-tags in a theme built on underscores in inc/template-tags
- Pages from admin dasboard missing after site migration
- $.ajax results in 403 forbidden
- Menu not updating for logged in users after redirect
- New user – Create a folder
- Change upload URL by mime type
- How To Add Custom User Meta During Registration
- How can I create a shortcode from an html and php code written together
- in the post admin, is it possible to make the post title input disabled using php?
- Serve cookie free URLs in WordPress without using a CDN
- How to send logs to plugin owner for a plugin?
- Where to check in PHPmyAdmin / SQL database for subdomain
- Save the outputted image into the Media Library, with a different filename and extension
- Add extra markup to WP menus
- allow previews outside wordpress folder (Outsourcing WP previews)
- Creating image gallery in wordpress
- Image limit from 1 to 5
- Splitting One Big WordPress Site into Multiple Small Sites
- How to link a word comprised of a custom field with another?
- get_category only returning details for ‘uncategorized’
- Can’t upload files
- Advanced Taxonomy query, with 3 post types
- PHP Widget and do_shortcode
- Add ASC / DESC to custom post columns
- Shortcode not passing variable to included file
- I can’t seem to get excerpts showing inside get_pages and don’t know why?
- Hide empty categories from get_categories
- image dimension in php code args
- I need a button to appear when not loged in and another when logged in, I need help fixing code PLEASE!
- Adding jquery using php function
- How to hide .js files on wordpress website using php or wp plugins or any? [closed]
- bloginfo url in javascript
- Add adjacent post function inside custom recent post function