How to know the user’s role?

[ad_1]

Hi there,

I created three new roles with this plugin. I know the names of the roles(written by myself in Chinese), but I want to get their English names in the code(just like “premium” or “standard” below), how can I get them? Which data table does WP store roles in? Thank you~

add_filter( ‘mwai_stats_credits’, function ( $credits, $userId ) {

$user = get_userdata( $userId );

if ( !empty( $user->roles) && is_array( $user->roles ) )

{ foreach ( $user->roles as $role)

{ if ( $role === ‘premium’ )

{ return 50; }

if ( $role === ‘standard’ )

{ return 10; } } } // This will be basically the default value set in the plugin settings // for logged-in users.

return $credits; }, 10, 2);

 

This site will teach you how to build a WordPress website for beginners. We will cover everything from installing WordPress to adding pages, posts, and images to your site. You will learn how to customize your site with themes and plugins, as well as how to market your site online.

Buy WordPress Transfer