HM CMB: Role Select

There is a list of roles in the $wp_roles WordPress global object. Set $wp_roles to a global at the top of your method of function: global $wp_roles; Use a Select Field to populate the options: array( ‘id’ => $prefix . ‘role’, ‘name’ => ‘Role’, ‘type’ => ‘select’, ‘use_ajax’ => false, ‘options’ => $wp_roles->get_names(), ), Note: … Read more

Get users with different roles and call function on each of them (user_meta)

First, always var_dump() something if you aren’t sure what exactly you got. If you ain’t got XDebug installed and configured, just use printf( ‘<pre>%s</pre>’, htmlspecialchars( var_export( $dumpMe, true ) ) ); which will bring up an equally informative response. About the WP_User_Query) IIRC it returns objects which are instances of WP_User. You can test that … Read more

Subscription list function

If you’d dumped one of your $players you’d have seen the issue: object(WP_User)#126 (7) { [“data”]=> object(stdClass)#129 (10) { [“ID”]=> string(1) “9” [“user_login”]=> string(3) “abc” [“user_pass”]=> string(34) “$P$BmwzlhY1xP6JTBlbWzLPetkx8lB.Zo/” [“user_nicename”]=> string(3) “abc” [“user_email”]=> string(19) “[email protected]” [“user_url”]=> string(0) “” [“user_registered”]=> string(19) “2013-10-04 09:22:08” [“user_activation_key”]=> string(0) “” [“user_status”]=> string(1) “0” [“display_name”]=> string(3) “abc” } [“ID”]=> int(9) // removed … Read more

Assigning multiple or additional capabilities to specific users or how to create additional roles like bbpress roles?

In WordPress is pretty simple create custom roles and also assign specific capabilities to specific user roles (no matter if from core or custom). In my plugins I often create an user role that has all the capabilities required by my plugin, and then I attach some of thos capabilities to existing roles. I’ll give … Read more

current-user_can not working in loop

From Codex : Do not pass a role name to current_user_can(), as this is not guaranteed to work correctly (see #22624) Instead, you may wish to try the check user role function put together by AppThemes. I would propose to use is_user_logged_in() to check your function.

Plugin permissions for Editor role

manage_options is an admin role so I’d still try and changing it even if you’ve changed the roles elsewhere. See http://codex.wordpress.org/Roles_and_Capabilities#Editor for more info. Try the following: add_options_page(‘Orbisius Simple Notice’, ‘Orbisius Simple Notice’, ‘edit_others_posts’, __FILE__, ‘orbisius_simple_notice_options_page’);

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