Hot answers tagged

2

This would be best as a comment, but no reputation :) In the codex they say "If you are defining a custom role, and adding capabilities to the role using add_role(), be aware that modifying the capabilities array and re-executing add_role() will not necessarily update the role with the new capabilities list. The add_role() function short-circuits if the ...


2

I would recommend the following: The Editor user role in WordPress cannot by default edit users. You may want to add that capability for clients whom you keep as 'Editors'. This will let the Editor add new users (create new users), delete users, and edit users. This is done by adding capabilities to the Editor role with 'add_cap'. This lets Editors ...


2

After writing those two lines in wp-config.php, your users data will be shared between both installations, but both installations will also need to have the same cookie parameters, so in wp-config.php file of your second installation, modify the COOKIE_DOMAIN like this: define('COOKIE_DOMAIN', '.{yoursite.com}'); //replace with URL of first site ...


2

Wordpress do not have a true concept of "logged in". Although the labels all around use the term, in the code the closest you get is something that might be called "authenticated users". The difference is that the authenticated user might be one that has his browser closed and therefor he is not "logged in". To do what you want you will first need to define ...


1

You can use pre_get_users since WP 4.0.0 function my_user_sort( $query_args ){ if( is_admin() && !isset($_GET['orderby']) ) { $query_args->query_vars['orderby'] = 'ID'; } return $query_args; } add_action( 'pre_get_users', 'my_user_sort' );


1

You can override the default query arguments using users_list_table_query_args: function wpse_214577_users_list_table_query_args( $args ) { if ( empty( $args['orderby'] ) ) $args['orderby'] = 'ID'; if ( empty( $args['order'] ) ) $args['order'] = 'ASC'; return $args; } add_filter( 'users_list_table_query_args', ...


1

Here is another approach in which we can answer the question, here is a small Plugin that adds a Submenupage for "Users", containing a small form where you can enter a username to create the new user with no emailadress. Additional Error handling allows you to see if the current user already exists, as usernames have to be unique. Create a ...


1

A quick (and dirty) solution would be to prevent the final deletion where it happens (function delete_user). You could implement a little plugin or paste the code into your functions.php: <?php /* Plugin Name: Please don't delete me! Description: Prevent accidental user deletion of my account */ define('PDDM_USER_ID', 1); // User ID of your Account ...


1

This is how you can get current user: global $current_user; $current_user = wp_get_current_user(); After that, you can use $current_user->ID where you want. Example: if ( is_user_logged_in() ) { $current_user = wp_get_current_user(); echo 'Username: ' . $current_user->user_login . '--'; echo 'User email: ' . ...


1

Prior to Wordpress 4.5 get_currentuserinfo() was an acceptable option, but is now deprecated, in favor of wp_get_current_user(). You can set the wp_get_current_user() as a variable to easily access it in your function or page: $current_user = wp_get_current_user(); Example: if ( is_user_logged_in() ) { $current_user = wp_get_current_user(); ...



Only top voted, non community-wiki answers of a minimum length are eligible