You should use WordPress functions to get the user role by user id. Please try code given below:
function user_role_parameter($user_id)
{
$user_meta = get_userdata($user_id);
if ( !empty($user_meta) ) {
$user_roles = $user_meta->roles;
$user_role="";
foreach( $user_roles as $role ){
$user_role .= $role . ', ';
}
return $user_role;
} else {
return "";
}
}
Related Posts:
- How to include checkbox in widget backend form?
- Using register_activation_hook in classes
- How to hide get_theme_mod if field empty
- renaming an admin menu item with decimal array index number
- How to get the original price of the product in woocommerce?
- How to use multiple query with same meta key
- How to make sure that only one wp_cron() runs at a time?
- How to create a custom config file and get data using inline JS in a wordpress page
- Replacing the NavWalker dropdown element
- Widgets not showing in my custom theme
- Edit category output
- integrating external php library into wordpress- the right way
- Getting the dropdown menu to redirect to different pages?
- To echo or not to echo?
- Different background-image by category
- enqueue multiple Google fonts with multiple weights and styles (italic)
- What is the fastest way to load PHP functions that are only used in one theme template?
- Writing scripts using WordPress / WooCommerce classes?
- storing wp_head in a variable?
- Get taxonomy terms only of the WP_Query current posts
- How do I attach a php file to an arbitrary slug and still have access to the wp-core functions?
- Accessing site’s root from themes folder
- Woocommerce redirect thankyou page based on product ID doesn’t empty Cart
- Passing PHP Function Arguments from CLI vs URL
- tracking number field in Woocommerce order [closed]
- Is_template how to add one more template [closed]
- How to complete two other input fields, completed the first
- Why ajax doesn’t work on certain wordpress hooks and reload the page instead?
- How to modify URL (add GET values) after front end form submission?
- How to add a do_action on refreshing of WP customizer?
- Error: options page not found
- WordPress displaying content from sub pages
- Filtering a Database Query
- Can’t save php string to a custom field
- Blob file download problem
- Appended comments but they show up above the content instead of below
- get_template_directory adding FTP root folders in urls
- Fatal error: Call to undefined function register_new_user()
- Remove the More Link
- Is there any wordpress plugin to upload images and captions to multiple pages once
- Removing the first 8-10 letters from a post?
- Site Health says I’m running an older version of PHP even after I upgraded to 7.4.4
- WordPress REST API register_rest_route give a 500 error
- Where to insert redirect code based on http_referer?
- How to display SQL query that ran in WC_Order_Query?
- Trying to get property of non-object in WordPress Breadcrumbs
- Delete database record using plugin from admin panel
- Post not populating for custom post type based on category selection
- How to display success message correctly and delete it when the page is refreshed
- Infinite Loop – WP_Query
- call_user_func_array() expects parameter 1 to be a valid callback, function ‘———-‘ not found or invalid function name
- How to display meta_value array?
- How can i make a search box to search by custom field
- ‘Bones’ theme: Load stock scripts in footer instead of header?
- go to home page when i select default in select-box
- Display Custom Field in Sidebar if Value is Present
- Update user repeater meta (ACF) with another user meta field value
- How to set post to draft and not publish if the_content contains certain words?
- Database entry removed on browser refresh, Ajax PHP jQuery
- Hide specific product from Woocommerce if the logged-in user has already enrolled into the course
- How to find which .mo file is responsible for displaying a particular localized string?
- is it possible for a URL to filter by tag
- Add Featured Image to Existing Post
- How to get latest post ID in functions.php?
- Preserving backslashes in post_content
- How to make a pagination with dropdown selection?
- Add to cart quantity dynamic
- Infinite looping next post link within a certain category on a post
- update_post_meta not working, but values are true
- Woocommerce – get daily sales meta
- Change CSS Variable value in Theme Customizer Live Preview
- Importing the style and scripts in the plugin doesn’t work as well as in the theme
- gettint error 400 with AJAX
- Show different number of posts on first Blog listing page
- Woocommerce textarea format ignored
- Windows Setup: Error establishing a database connection
- Pass product object to javscript
- remove blank space where sidebar was
- Change username link in admin bar
- Using Tag Groups: Displaying groups and adjacent tags of current post
- Custom theme: adding unwanted tags in the content
- How to change this internal image link parameter using PHP?
- File path for attachments outside of wp-content/uploads
- How to save the output of php variables used in inline css code to the main style.css?
- How to show all of aspecific post type that has taxonomy and a specific term
- How can i call the facebook #hashtag images on my site
- Error trying import one category on page
- Banner editable from backend
- URL prefix to include one PHP page
- Adding else if conditional statement to purchased theme
- Reusing the page name class that WordPress adds to body tag
- Crop images in both sides on wordpress [duplicate]
- Query category name by variable
- archive per year with monthly
- Check if username doesn’t exists
- How do I remove blog entries from home page Twenty Eleven child theme?
- How can I update a value of a field depending on outside source?
- Restricting access to a file for everyone except logged in users
- WordPress Block Editor Gutenberg running code inside ! is_admin()
- Tags being Inserted in html from plugin PHP not passing through the_content