How to know the user’s role?
-
Hi, Jordy,
I created three new roles with another 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”), how can I get them? Which data table does WP store roles in? Thank you~
dd_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);
The page I need help with: [log in to see the link]
- The topic ‘How to know the user’s role?’ is closed to new replies.