Check logged in user role in WordPress

Check logged in user role. Use function  wp_get_current_user() to get the current/logged in user info.

Usage:

var_dump( prefix_user_has_role( 'administrator' ) );

// Output:
// bool(true)

Snippet:

Advertisements

Author: maheshwaghmare

WordPress Developer since 2012.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

w

Connecting to %s