Check role of Username then echo something if administrator [closed]

@terminator answer might work but there’s no need to create an array and use array_intersect I think since you’re only looking for one role. This might be more comprehensible: $current_user = wp_get_current_user(); $roles = (array) $current_user->roles; if (in_array(‘administrator’, $roles) { /* echo whatever */ } Don’t forget to check that ‘administrator’ is acutally the role … Read more

is wordpress stores Role Id in WP database?

The “ID” of the role is the array key in wp_user_roles. The value of wp_user_roles looks like this: Array ( [administrator] => Array ( [name] => Administrator [capabilities] => Array ) => Array ( [name] => Author [capabilities] => Array ) ) In that example, administrator and author are the closest thing there is to … Read more

How do I let contributors edit their posts after being approved once?

There is a capability in WordPress called “edit_published_posts”. Contributors do not have this capability by default (refer to the Roles and Capabilities Codex page to see the out-of-box role configurations). You can add this capability to the contributor role with code like this: // get the “contributor” role object $obj_existing_role = get_role( ‘contributor’ ); // … Read more

reset the users roles – is there a way to do this?

The easiest way I know to reset roles and their associated capabilities is to use wp-cli. wp-cli has a built-in method for resetting roles. You can specify any that you want to reset. For example: wp role reset author contributor editor subscriber There is also an –all flag, which you can use like this: wp … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)