How to assign capabilities to user NOT to User Role

Finally, I’ve figured out a way to do it using WP_user Class. Snippet to add/remove capability to/from specific user – //to remove capability from user $user = new WP_User( $user_id ); $user->remove_cap( ‘can_email’); //to add capability to user $user = new WP_User( $user_id ); $user->add_cap( ‘can_email’); There is special function in capabilities.php in the wp_user … Read more

Sort users in get_users() in custom order

There is a simpler, faster method than the one by @Warface. This is an extention to @SyHolloway The concept here is to wrap get_users() in a new function in which you can sort the result from get_users() by the include parameter using usort and then return the resulted array sorted by include This function does … Read more

Sort get_users by custom field

By using this you can get your result in ascending order for sort_order custom field $users = get_users( array( ‘meta_key’=> ‘sort_order’, ‘orderby’ => ‘meta_value_num’, ‘order’ => ‘ASC’ ) ); foreach( $users as $user ) { echo ‘<h4>’ . $user_info-> user_firstname . ‘ ‘ . $user_info-> user_lastname . ‘</h4>’; }

How to change WordPress user ID?

Why not make a new account for this user which will generate a new database ID. Then delete the user with the ID of 1 and attribute all posts / content to the new user you created for them? Then you don’t have to worry about queries or messing up your database. Also, as said … Read more

Custom taxonomy on users with UI

Answering this question is, by design, a multi-part process. There are several things you (or a plugin/library) need to do to make User Taxonomies behave similarly to Post Taxonomies, even after you have (successfully) registered it. This answer is a work-in-progress to some degree. Please add other answers with solutions to any aspects that are … Read more

Set user after wp_create_user?

Here is a function I wrote that hooks into the gravity forms create user form but it can be added to whatever action hook your wp_create_user function is attached to. function my_auto_login( $user_id ) { wp_set_auth_cookie( $user_id, false, is_ssl() ); wp_redirect( admin_url( ‘profile.php’ ) ); exit; } The important part is wp_set_auth_cookie. This has to … Read more

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