How to get the Role Name of the current user? (WordPress)

I’m not sure if bbPress follows WordPress conventions, but WP has a global class called $WP-roles that holds the role information. So, starting from what you have, there is the role of the current user: $current_role = $user->roles[1]; Next, retrieve a list of all roles: $all_roles = $wp_roles->roles; Then, loop through $all_roles and find the … Read more

What is the difference between “create_users” and “add_users” capabilities?

I explored WordPress to find difference between it and in schema.php file i found the following function only where in WordPress add_users capability is used. /** * Create and modify WordPress roles for WordPress 3.0. * * @since 3.0.0 */ function populate_roles_300() { $role =& get_role( ‘administrator’ ); if ( !empty( $role ) ) { … Read more

Is there a simple way to manage capabilities per user?

You don’t necessarily have to assign roles to manage the user’s capabilities. First, register your custom post types with their respective capabilities. See capabilities under Function Reference/register post type – Parameters Managing User Capabilities You can use add_cap or remove_cap to add or remove user capabilities for a specific user. // Add capability to a … Read more

How are roles stored in the database?

The core functions: is_super_admin(), grant_super_admin(), revoke_super_admin() fetch the super admins data from the wp_sitemeta table with: $super_admins = get_site_option( ‘site_admins’, array( ‘admin’ ) ); It’s stored as a serialized array of user logins, for each site, like: a:1:{i:0;s:6:”louiev”;} It’s possible to override it with the global $site_admins array. On the other hand, the general user … Read more

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