Process.getcurrentprocess method

wp user list

Список пользователей.


Display WordPress users based on all arguments supported by WP_User_Query().

Использование

wp user list      

Можно указать Глобальные параметры и следующие:

Only display users with a certain role.
Control output by one or more arguments of WP_User_Query().
List all users in the network for multisite.
Prints the value of a single field for each user.
Limit the output to specific object fields.

Render output in a particular format. По умолчанию: table Может быть:

  • table
  • csv
  • ids
  • json
  • count
  • yaml

Доступные поля

These fields will be displayed by default for each user:

  • ID
  • user_login
  • display_name
  • user_email
  • user_registered
  • roles

These fields are optionally available:

  • user_pass
  • user_nicename
  • user_url
  • user_activation_key
  • user_status
  • spam
  • deleted
  • caps
  • cap_key
  • allcaps
  • filter
  • url

Примеры

# List user IDs
$ wp user list --field=ID
1
# List users with administrator role
$ wp user list --role=administrator --format=csv
ID,user_login,display_name,user_email,user_registered,roles
1,supervisor,supervisor,supervisor@gmail.com,"2016-06-03 04:37:00",administrator
# List users with only given fields
$ wp user list --fields=display_name,user_email --format=json
# List users ordered by the 'last_activity' meta value.
$ wp user list --meta_key=last_activity --orderby=meta_value_num

Troubleshooting # Troubleshooting

If anything has gone wrong, then the first thing to do is go through all the steps in our extended upgrade instructions. That page also has information about some of the most common problems we see.

If you run into a request for FTP credentials with trying to update WP on a IIS server automatically, it may well be a matter of rights. Go into the IIS Management Console, and there to the application pool of your blog. In its advanced settings, change the Process Model Id into LocalSystem. Then on Sites, choose your blog, right click, click on Edit permissions and on security tab add authenticated users. That should do it.

If you experience problems after the upgrade, you can always restore your backup and replace the files with ones from your previous version from the release archive.

Summary of Roles # Summary of Roles

  • – somebody with access to the site network administration features and all other features. See the Create a Network article.
  • (slug: ‘administrator’) – somebody who has access to all the administration features within a single site.
  • (slug: ‘editor’) – somebody who can publish and manage posts including the posts of other users.
  •  (slug: ‘author’)  – somebody who can publish and manage their own posts.
  • (slug: ‘contributor’) – somebody who can write and manage their own posts but cannot publish them.
  • (slug: ‘subscriber’) – somebody who can only manage their profile.

Upon installing WordPress, an Administrator account is automatically created.

The default role for new users can be set in Administration Screens > > General.

Roles # Roles

A Role defines a set of tasks a user assigned the role is allowed to perform. For instance, the Super Admin role encompasses every possible task that can be performed within a of virtual WordPress . The role limits the allowed tasks only to those which affect a single site. On the other hand, the role allows the execution of just a small subset of tasks.

The following sections list the default Roles and their capabilities:

Super Admin

Multisite Super Admins have, by default, all capabilities. The following Multisite-only capabilities are therefore only available to Super Admins:

In the case of single site WordPress installation, Administrators are, in effect, Super Admins. As such, they are the only ones to have access to .

Administrator

The capabilities of Administrators differs between single site and WordPress installations. All administrators have the following capabilities:

  • create Reusable Blocks
  • edit Reusable Blocks
  • read Reusable Blocks
  • delete Reusable Blocks

Additional Admin Capabilities

Only Administrators of single site installations have the following capabilities. In , only the Super Admin has these abilities:

Special Cases

The following capabilities are special cases:

unfiltered_upload – This capability is not available to any role by default (including Super Admins). The capability needs to be enabled by defining the following constant:

With this constant defined, all roles on a single site install can be given the unfiltered_upload capability, but only Super Admins can be given the capability on a Multisite install.

Capability Super Admin Administrator Editor Author Contributor Subscriber
create_sites Y
delete_sites Y
manage_network Y
manage_sites Y
manage_network_users Y
manage_network_plugins Y
manage_network_themes Y
manage_network_options Y
upload_plugins Y
upload_themes Y
upgrade_network Y
setup_network Y
Capability Super Admin Administrator Editor Author Contributor Subscriber
activate_plugins Y Y (single site or enabled by network setting)
create_users Y Y (single site)
delete_plugins Y Y (single site)
delete_themes Y Y (single site)
delete_users Y Y (single site)
edit_files Y Y (single site)
edit_plugins Y Y (single site)
edit_theme_options Y Y
edit_themes Y Y (single site)
edit_users Y Y (single site)
export Y Y
import Y Y
Capability Super Admin Administrator Editor Author Contributor Subscriber
install_plugins Y Y (single site)
install_themes Y Y (single site)
list_users Y Y
manage_options Y Y
promote_users Y Y
remove_users Y Y
switch_themes Y Y
update_core Y Y (single site)
update_plugins Y Y (single site)
update_themes Y Y (single site)
edit_dashboard Y Y
customize Y Y
delete_site Y Y
Capability Super Admin Administrator Editor Author Contributor Subscriber
moderate_comments Y Y Y
manage_categories Y Y Y
manage_links Y Y Y
edit_others_posts Y Y Y
edit_pages Y Y Y
edit_others_pages Y Y Y
edit_published_pages Y Y Y
publish_pages Y Y Y
delete_pages Y Y Y
delete_others_pages Y Y Y
delete_published_pages Y Y Y
delete_others_posts Y Y Y
delete_private_posts Y Y Y
edit_private_posts Y Y Y
read_private_posts Y Y Y
delete_private_pages Y Y Y
edit_private_pages Y Y Y
read_private_pages Y Y Y
unfiltered_html Y Y (single site) Y (single site)
unfiltered_html Y Y Y
Capability Super Admin Administrator Editor Author Contributor Subscriber
edit_published_posts Y Y Y Y
upload_files Y Y Y Y
publish_posts Y Y Y Y
delete_published_posts Y Y Y Y
edit_posts Y Y Y Y Y
delete_posts Y Y Y Y Y
Capability Super Admin Administrator Editor Author Contributor Subscriber
read Y Y Y Y Y Y

Related #Related

Uses

Uses
Uses
wp-includes/l10n.php: restore_previous_locale()
wp-includes/l10n.php: switch_to_locale()
wp-includes/l10n.php: get_user_locale()
wp-includes/user.php: send_email_change_email
wp-includes/user.php: password_change_email
wp-includes/user.php: email_change_email
wp-includes/user.php: send_password_change_email
wp-includes/l10n.php: __()
wp-includes/formatting.php: wp_specialchars_decode()
wp-includes/pluggable.php: wp_hash_password()
wp-includes/pluggable.php: wp_clear_auth_cookie()
wp-includes/pluggable.php: wp_parse_auth_cookie()
wp-includes/pluggable.php: wp_set_auth_cookie()
wp-includes/pluggable.php: auth_cookie_expiration
wp-includes/pluggable.php: get_userdata()
wp-includes/pluggable.php: wp_mail()
wp-includes/pluggable.php: wp_get_current_user()
wp-includes/functions.php: add_magic_quotes()
wp-includes/link-template.php: home_url()
wp-includes/plugin.php: apply_filters()
wp-includes/option.php: get_option()
wp-includes/user.php: _get_additional_user_keys()
wp-includes/user.php: clean_user_cache()
wp-includes/user.php: wp_insert_user()
wp-includes/user.php: get_user_meta()
wp-includes/load.php: is_wp_error()
wp-includes/class-wp-error.php: WP_Error::__construct()

Related #Related

Uses

Uses
Uses
wp-includes/user.php: wp_pre_insert_user_data
wp-includes/user.php: insert_user_meta
wp-includes/user.php: illegal_user_logins
wp-includes/user.php: make_spam_user
wp-includes/user.php: make_ham_user
wp-includes/class-wp-user.php: WP_User::__construct()
wp-includes/l10n.php: __()
wp-includes/l10n.php: _x()
wp-includes/formatting.php: wp_unslash()
wp-includes/formatting.php: sanitize_user()
wp-includes/formatting.php: sanitize_title()
wp-includes/pluggable.php: wp_hash_password()
wp-includes/pluggable.php: get_userdata()
wp-includes/load.php: is_multisite()
wp-includes/plugin.php: apply_filters()
wp-includes/plugin.php: do_action()
wp-includes/option.php: get_option()
wp-includes/user.php: wp_get_user_contact_methods()
wp-includes/user.php: profile_update
wp-includes/user.php: user_register
wp-includes/user.php: username_exists()
wp-includes/user.php: email_exists()
wp-includes/user.php: clean_user_cache()
wp-includes/user.php: pre_user_login
wp-includes/user.php: pre_user_nicename
wp-includes/user.php: pre_user_email
wp-includes/user.php: pre_user_url
wp-includes/user.php: pre_user_nickname
wp-includes/user.php: pre_user_first_name
wp-includes/user.php: pre_user_last_name
wp-includes/user.php: pre_user_display_name
wp-includes/user.php: pre_user_description
wp-includes/user.php: update_user_meta()
wp-includes/wp-db.php: wpdb::get_var()
wp-includes/wp-db.php: wpdb::update()
wp-includes/wp-db.php: wpdb::insert()
wp-includes/wp-db.php: wpdb::prepare()
wp-includes/class-wp-error.php: WP_Error::__construct()

Manual Update # Manual Update

These are the short instructions, if you want more check out the extended upgrade instructions. If you experience problems with the Three Step Update, you may want to review the more detailed upgrade instructions.

For these instructions, it is assumed that your blog’s URL is .

Step 1: Replace WordPress files

  1. Get the latest WordPress zip (or tar.gz) file.
  2. Unpack the zip file that you downloaded.
  3. Deactivate plugins.
  4. Delete the old  and  directories on your web host (through your FTP or shell access).
  5. Using FTP or your shell access, upload the new  and  directories to your web host, in place of the previously deleted directories.
  6. Upload the individual files from the new  folder to your existing  folder, overwriting existing files. Do NOT delete your existing  folder. Do NOT delete any files or folders in your existing  directory (except for the one being overwritten by new files).
  7. Upload all new loose files from the root directory of the new version to your existing WordPress root directory.

NOTE – you should replace all the old WordPress files with the new ones in the  and  directories and sub-directories, and in the root directory (such as , and so on). Don’t worry – your will be safe.

Be careful when you come to copying the directory. You should make sure that you only copy the files from inside this directory, rather than replacing your entire directory. This is where your themes and plugins live, so you will want to keep them. If you have customized the default or classic themes without renaming them, make sure not to overwrite those files, otherwise you will lose your changes. (Though you might want to compare them for new features or fixes..)

Lastly you should take a look at the file, to see if any new settings have been introduced that you might want to add to your own .

Step 1.5: Remove .maintenance file

If you’re upgrading manually after a failed auto-upgrade, delete the file .maintenance from your WordPress directory using FTP. This will remove the “failed update” nag message.

Step 2: Update your installation


Visit your main WordPress admin page at /wp-admin. You may be asked to login again. If a database upgrade is necessary at this point, WordPress will detect it and give you a link to a URL like . Follow that link and follow the instructions. This will update your database to be compatible with the latest code. You should do this as soon as possible after step 1.

Don’t forget to reactivate plugins!

Step 3: Do something nice for yourself

If you have caching enabled, clear the cache at this point so the changes will go live immediately. Otherwise, visitors to your site (including you) will continue to see the old version (until the cache updates).

Your WordPress installation is successfully updated. That’s as simple as we can make it without Updating WordPress Using Subversion.

Consider rewarding yourself with a blog post about the update, reading that book or article you’ve been putting off, or simply sitting back for a few moments and letting the world pass you by.

Functions on user lists

These functions load multiple users, not just individual elements.

WP_User_Query class

The class allows to load a list of users based on different criteria. Although it is not a function, it’s worth mentioning it here, as it is a very common way of loading users. It provides many different search options, including custom ordering and pagination options. When loading users with , all the query parameters are passed as an array to the class constructor. Then, to load the user list, we need to call the method. All of the available parameters and methods are described in the reference.

Here is an example of loading the last 10 registered subscribers:

1 2 3 4 5 6 7

$query=newWP_User_Query(array(

‘role’=>’Subscriber’,

‘number’=>10,

‘orderby’=>’user_registered’,

‘order’=>’DESC’

));

$users=$query->get_results();

get_users()

This is a simpler way to load a list of users. The function actually uses under the hood. It can be used for multiple arguments and you can combine a lot of them at once. This is surely the most complete function and replaces some of the deprecated functions as well. You can find the full list of accepted arguments on the function guide.

Here is the same example of loading the last 10 registered subscribers, this time by using the function:

1 2 3 4 5 6

$users=get_users(array(

‘role’=>’Subscriber’,

‘number’=>10,

‘orderby’=>’user_registered’,

‘order’=>’DESC’

));

wp_dropdown_users()

This is an interesting function to load WordPress users and create a dropdown for user selection. This may be useful for plugins that change user settings or assign users to data. It has some arguments used for user filtering and output preparing as well – you can find the full list in the function reference here.

Let’s see an example for this function. It could be used for an interactive author archive or team page. Then you list them as a dropdown and as your users change options your page reacts to reload your content. Here is how to display the authors:

1 wp_dropdown_users(array(‘who’=>’authors’));

An this is how the dropdown looks on the front-end:

count_many_users_posts()

This function gets many post counts for a list of user IDs. When you need to load the number of posts for a list of users, you should use this function instead of calling the  function for each user. That’s because  will make a single database query for the full list of users, while  will make a separate query for each user. In this way you may end up doing hundreds of database queries at once.

1 2 3 4 5 6

$users=count_many_users_posts(array(1,2,3,4));


echo»<h2>Posts made by our authors</h2>»;

foreach($usersas$user=>$count){

echo»ID: «.$user.» — Count: «.$count.»<br />»;

}

Reviews

http-equiv=»Content-Type» content=»text/html;charset=UTF-8″>lass=»plugin-reviews»>

wp kompatibilitási hibát írt ki 5,3 mas wp vel

There are many, many useful settings for those wishing to customize users and forms. Many features are standard in this plugin where others dev’s charge for them.

Plugin Developer is responsive to issues and suggestions.

No reason found not to give 5 star rating.

Tried each and every similar form, no matter how fancy they sound, but this one really gives what it claims it does. Simple, fast, many options, super great support even for the non-paid version, beautiful design, to the point… etc. All the best for the developers.

Plugin looks nice and would fit my needs but:

Aside from that it has very nice look but still broken here and there

good

Basically it’s working but I’m encountering this message on my profile (user) page, in «My Account», «Edit Profile», and «Contact Us» tabs:

Warning: Illegal string offset ‘form_id’ in /app/public/wp-content/plugins/wp-user/user/view/profile.php on line 177 Warning: Illegal string offset ‘wpuser_update_setting_nonce’ in /app/public/wp-content/plugins/wp-user/user/view/profile.php on line 178

Any updates/bugfix for this?

Thanks.

Single user functions

wp_get_current_user()

Here is a simple example, let’s display a welcome message for our users:

1 2

$user=wp_get_current_user();

echo»Welcome, «.$user->display_name.»! It’s great to see you here.»;

In case you are wondering the main elements of the WordPress user object you get with this function is something like this:

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21

WP_User Object(

‘data’=>stdClass Object(

‘ID’=>1,

‘user_login’=>’admin’,

‘user_pass’=>$hash,

‘user_nicename’=>’admin’,

‘user_email’=>’email@domain.com’,

‘user_registered’=>’2017-03-08 13:10:44’,

‘display_name’=>’John Doe’

),

‘ID’=>1,

‘caps’=>Array(//shorthand version of capabilities

‘administrator’=>1

),

‘roles’=>Array(//all user roles listed

‘0’=>rolename

),

‘allcaps’=>Array(//all user capabilities

‘capname’=>1

)

)

Once you have the object, you can read and update different properties of the user. You can read more about the available user object methods and properties in the WP_User class reference page.

get_current_user_id()

This function is a quick way to load just the ID of the currently logged in user. Although it is similar to the previous function it is much quicker and has its use cases where you don’t need the full WordPress User Object. For instance, you may want to add a custom user meta field to users who visit a specific page. This can be used so you know later that they have seen it, and when this happened. You don’t need anything else beyond the user ID and the current timestamp for that.

1 2 3

$user_id=get_current_user_id();

//updates the visit custom field with the latest timestamp

update_user_meta($user_id,’visit’,time());

This function simply returns the user ID or false in case the user is a guest visitor.

1 return(false|(int)$userID)

get_user_by()

This function allows you to find a user based on different user properties. Unlike the above-mentioned functions, this one allows you to access any user – not only the currently logged in user. This is particularly useful for admins, so they can search and modify users using this function.


The function accepts many arguments for the fields (what you want to search for) and any string for values. Here are the accepted arguments for the fields:

  • id – look for specific user ID
  • ID – just an alias for above
  • slug – return users based on their user_nicename (which is a URL sanitized version of the username)
  • email – search users based on email
  • login – filter users based on their username
1 $user=get_user_by(’email’,’john@john.com’);

This function returns a object when a user with the search condition is found. Otherwise, it would return .

get_userdata()

This function is a quick shorthand to find a user by ID. Here is a quick example, in case you want to debug a user:

1 $user=get_userdata(1);

Similarly this function returns a object when a user with the specified ID is found. If there is no user with this ID, the function would return .

count_user_posts()

This function returns the total posts a user has created. It can be used with just specific custom post types. Additionally, you can ignore private posts. This comes in handy for system-type content, or custom post types used just for metadata.

Here is an example of how to use this function for a quick overview of your authors:

1 2

$post_count=count_user_posts(get_current_user_id());

echo»You have created $post_count posts»;

Get User ID by First Name or by Last Name

Print the ids of all users with the first name is «Misha»:

global $wpdb;
$users = $wpdb->get_results( "SELECT user_id FROM $wpdb->usermeta WHERE meta_key = 'first_name' AND meta_value = 'Misha'" );
if( $users ) {
	foreach ( $users as $user ) {
		echo '<p>' . $user->user_id . '</p>';
	}
} else {
	echo 'There are no users with the specified first name.';
}

Print the ids of all users with the last name is «Rudrastyh»:

global $wpdb;
$users = $wpdb->get_results( "SELECT user_id FROM $wpdb->usermeta WHERE meta_key = 'first_name' AND meta_value = 'Rudrastyh'" );
if( $users ) {
	foreach ( $users as $user ) {
		echo '<p>' . $user->user_id . '</p>';
	}
} else {
	echo 'There are no users with the specified last name.';
}

The code above will work if you would like to find user ID by any user meta value. Just replace and with the ones you need.

And of course you can get user first and last names and any meta with the help of function.

Reviews

http-equiv=»Content-Type» content=»text/html;charset=UTF-8″>lass=»plugin-reviews»>

I have been using UWP for almost a year now and have only pleasent experience to share with you all, whether it’s the easy to understand and use interface of UWP or a resolution of an issue.

I have not only raised issues but have given my suggestions as well and each time, my messages have been received well and a resolution provided.

Manish

I’ve been very happy with the level of support from the Ayecode team. I also like how the plugin continues to improve upon itself, adding more functionality as it grows. Keep up the good work!

This is my first time leaving a review but that’s because THIS PLUGIN IS PERFECT. I’ve been looking for something for ages. It’s complete. Not overly done. Simply to configure. Seriously. PLEASE CONTINUE UPDATING THIS PLUGIN.

In the past 12 months, I think I’ve tested all the free plugins and many paid plugins without being completely satisfied, as if I was left hungry, severely in the dark. So, with usersWP, I too want to say: FINALLY! A plugin developed intelligently, with just the necessary options because certain configurations are done automatically by logical deduction of the fields activated or not. Being a senior developer myself, I usually add my own code to free plugins. But this time, it was with pleasure that I agreed to pay for the Modarator addon, the code of which is certainly of much better quality than what I could have produced myself. Even if it’s free, the quality of the code is here and the support is very responsive. I extend my encouragement to the team.

I bought the premium license of the plugin and installed the following plugin, but it didn’t work. It was compatible with the WordPress theme and compatible plugin. My goal is to use the userswp plugin, disable all other installed plugins, change the theme and try again and again but it didn’t work again. I contacted the plugin writer by default, but I did not get any results. Finally, I requested a refund of the fee I paid for the premium license. I expect them to return.

EDİT: The plugin writer was interested in my error and resolved the problem soon. Due to the late support that coincides with the weekend, I increase 1 star to 4 stars. Thank you userswp team

plugin used to work quite well and then suddenly I get this message «Oops! That page can’t be found.» while I try to get to users profiles !!!!

Add the User ID column to the WordPress Users Table

Very useful way of getting user ids through WordPress admin. Here is the result:

How to create the same column on you own WordPress website? All you need to do is to copy the following code to you current theme file:

/*
 * Adding the column
 */
function rd_user_id_column( $columns ) {
	$columns'user_id' = 'ID';
	return $columns;
}
add_filter('manage_users_columns', 'rd_user_id_column');
 
/*
 * Column content
 */
function rd_user_id_column_content($value, $column_name, $user_id) {
	if ( 'user_id' == $column_name )
		return $user_id;
	return $value;
}
add_action('manage_users_custom_column',  'rd_user_id_column_content', 10, 3);
 
/*
 * Column style (you can skip this if you want)
 */
function rd_user_id_column_style(){
	echo '<style>.column-user_id{width: 5%}</style>';
}
add_action('admin_head-users.php',  'rd_user_id_column_style');

Misha Rudrastyh

I love WordPress, WooCommerce and Gutenberg so much. 11 yrs of experience.

Need some custom developer help? Get in touch


С этим читают