All Questions
254 questions
20
votes
3
answers
32k
views
user_login vs. user_nicename
When you call the get_users() functions, a list of user objects are returned. Each of those users has a number of properties. What is the difference between user_login and user_nicename in those ...
16
votes
10
answers
37k
views
Adding fields to the "Add New User" screen in the dashboard
I'd like to add the field "Company Name" to the add new user page in the admin panel. I've done quite a bit of searching and have been unable to find details on how to do this. I can easily add info ...
14
votes
2
answers
3k
views
Difference between update_user_meta and update_user_option
Can anyone explain what is the difference between update_user_meta and update_user_option and in which scenarios the both can be used?
12
votes
7
answers
27k
views
How to filter users on admin users page by custom meta field?
The Problem
WP appears to remove the value of my query variable before it gets used to filter the list of users.
My Code
This function adds a custom column to my Users table on /wp-admin/users.php:
...
11
votes
3
answers
42k
views
get_user_meta() doesn't include user email?
I simply wonder why <?php var_dump(get_user_meta(4)); ?> doesn't contain an email address of the user. Instead I have to use
get_userdata(4)->user_email; to query the email of the user.
...
10
votes
3
answers
20k
views
Check if user is admin by user ID
Any ideas how to check if user (by user ID) is administrator? I don't mean currently logged in user.
8
votes
1
answer
2k
views
Automatically delete inactive users after 2 months
I am trying to modify this function:
// automatically delete users after 7 days in wordpress
function wcs_auto_delete_users() {
global $wpdb;
$query = $wpdb->prepare( "SELECT ID FROM $wpdb->...
6
votes
1
answer
29k
views
Return all users with a specific meta key
I'd like to use get_users() to return all users that have a particular meta_key, but I don't want to specify what the value has to be because it will change for every user. The value is a json string. ...
6
votes
2
answers
20k
views
How to display custom user meta from registration in backend?
I'm considering using the hooks for the WordPress registration form to add some custom fields: https://codex.wordpress.org/Customizing_the_Registration_Form
My question is, if it's even possible, how ...
5
votes
1
answer
10k
views
Where the Nickname is being used in WordPress
I see most of the place is using the "Display name", so why I need to set a Nickname?
Where it is being used?
5
votes
2
answers
4k
views
Allowing an email as the username?
Is it possible to allow people to utilize their email as their username?
5
votes
1
answer
4k
views
Grouping users under parent user
What it needs to be like:
one "super user" with user role company
normal users with user role employee
I don't want "super user" to be able to have more capabilities, especially admin-like ...
5
votes
2
answers
1k
views
get_users is expecting unserialized meta_value
I'm trying to get all users assigned to a custom usermeta. I know that get_users() is supposed to work; however, it doesn't seem to be working. What I have is a usermeta storing a category ID and I'm ...
4
votes
5
answers
20k
views
How we can get the user id by its display_name
I have user display_name and with this I want to get the id of that user.
So, how can I get the user id?
4
votes
1
answer
18k
views
How to get users by a custom field / by user meta data?
I've added a custom field to users profile using the following code:
/*** Adding extra field to get the the user who creates the another user during ADD NEW USER ***/
<?php
function ...
4
votes
1
answer
556
views
How to create a template for a custom URI associated with the user
I am working on a site where I am using a plugin called Favorite Posts so logged-in users can add a post (a custom post type) to their favorites.
I created a page called my-favorites which allows the ...
4
votes
3
answers
10k
views
How to order users alphabetically by their last name?
I use the following shortcode and function to display members of some departments:
add_shortcode( 'list_of_members', 'members_listing' );
/* usage: [list_of_members department = 'psychology'] */
...
4
votes
1
answer
8k
views
Getting all user metadata from user
I am trying to show bio and other custom metadata for my users in a page. So, i want to query the user metadata table for it. I have tried but did not find any functions for that.
What i am looking ...
4
votes
1
answer
4k
views
How do you add a custom option to user data?
I would like to add avatars to my users. I have a limited group on a site I'm working. Uploading isn't really a problem we can just put the images on the server and use URL's to set our avatars(Only ...
4
votes
3
answers
3k
views
Extending WP_User class and using this sub-class during the whole lifecycle
What I am trying to achieve is the following: for every user on our website, I want to do an API request to a service (local REST API interacting with another database) once and then cache the result ...
4
votes
1
answer
578
views
Wp_User_Query not sorting by meta key
I'm trying to list users sorted by a meta value. I store a score for each user in their user meta which is just a number but the loop isn't sorting. I include the score in the loop so that I can see ...
3
votes
2
answers
9k
views
Add a button to users.php
I am working on a plugin that adds meta data for each user to the users.php table that is displayed by adding columns. I have that done but I would like to also add a button that will delete the meta ...
3
votes
2
answers
14k
views
Show User Their Password
I've got a few automated scripts that run to notify users of certain updates to the application, etc... and for one in particular, I need to be able to display the users user_login and their password.
...
3
votes
1
answer
3k
views
Extend the wp_users table
I'd like to to extend the wp_users table in my WordPress' database.
Why? I want people to add more information about themselves when they sing up at my website.
I know how to extend it, but I'm ...
3
votes
1
answer
11k
views
WP_User_Query with combined meta query - not working?
I'm trying to use WP_User_Query class to list all users basing on their specific meta fields.
When I use simple single-meta query, it works fine:
$q = new WP_User_Query( array(
'role' => ...
3
votes
2
answers
2k
views
How to use hyperdb to separate and share a user dataset between wordpress installs?
I'm looking for a way to separate my users and usermeta table to be in a different database than my main WP install. The end goal is sharing these table over a number of WP installs.
From what I read,...
3
votes
3
answers
5k
views
LEFT JOIN, INNER OUTER JOIN, LEFT OUTER JOIN is driving me crazy. Please help?
fellow coders! I an having a hard time JOIN(ing) tables.
I have a a lot of users on my site and many of them have the same last names. I am trying to get their emails by their last name. WP stores ...
3
votes
1
answer
943
views
\WP_User Object | What's the Difference Between {caps} and {allcaps}?
Upon dumping the \WP_User object, I've noticed that there are two properties, which are directly related to capabilities for a particular user.
$user_object->caps
$user_object->allcaps
I've ...
3
votes
1
answer
2k
views
Show Biographical Info while creating new user
Is it possible to show the Biographical Info textfield while creating a new user?
I know it's possible to add user bio by editing a user AFTER it has been created. But I would like to do this while ...
3
votes
1
answer
2k
views
include user profiles in search results?
I have a need to include user profiles, along with posts & pages, in front-end searches.
I've searched for solutions to this problem (both here on WSE and elsewhere on the web) and haven't found ...
3
votes
2
answers
3k
views
How to add follow functionality to multi-author wordpress site?
is there any way to add "follow" functionality to Wordpress ?
so that every logged-in user can follow his favorite author
and only can see post from authors that he followed them ..
A possible ...
3
votes
2
answers
2k
views
Search multiple meta keys at once
How would I modify the following SQL Query to allow me to search multiple meta keys at once? e.g. user_business AND user_about
In the end I'll be searching about 40 - 50 different meta keys; or if ...
3
votes
2
answers
3k
views
How may I filter get_users() similarly to pre_get_posts?
I have filtered posts, pages and custom_post_types based on $current_user custom usermeta field values using pre_get_posts().
Is there a similar method/function to alter get_users() based on $...
3
votes
1
answer
564
views
Where to Store Custom User Fields
I've built an enterprise Wordpress site and we are currently designing an automated import of company user data directly into the Wordpress database, so it's not manual. This user data has more data ...
3
votes
0
answers
2k
views
Searchable meta value in user.php
I have created a new column in the user table list (admin page) and would like the column to be searchable in the search query, How do i add the meta to the search users query ?
/**
* Create user ...
3
votes
0
answers
2k
views
How to add quick edit and bulk edit fields to users admin section
Salutations, is there a way to add quick edit and bulk edit fields for the users section in wordpress. I have found a lot about post types and custom post types but i'm specifically looking to add ...
2
votes
2
answers
11k
views
How to get the user description with get_users?
I'm using this piece of code to list users and their information. The problem I'm having is that the description isn't showing. Obviously it's because the description lays under "user_meta" and not "...
2
votes
1
answer
6k
views
Users table missing from Database [closed]
I have a functioning WordPress site, with two users (an Administrator and an Editor). I can log in to the WP back-end fine with either user. I can create pages, etc. But when I look at phpMyAdmin, ...
2
votes
1
answer
2k
views
Hide a user from WordPress
I'm using the below code to hide a user from the WordPress User List:
add_action( 'pre_user_query', 'ap_pre_user_query' );
function ap_pre_user_query( $user_search ) {
$user = wp_get_current_user(...
2
votes
3
answers
11k
views
Drop down list in user profile page
I am having problems finding an answer to this. I need to have a custom user meta field.
I can create them which is fine but I need to create a drop down one.
For example I want the user meta to ...
2
votes
1
answer
1k
views
Uncheck the box "Send User Notification" by default on new-user.php
I'm looking for a way to uncheck the box by default when we create a new user on WordPress.
Right now it is checked when we access wp-admin/user-new.php like you can see on the screenshot below:
...
2
votes
1
answer
4k
views
Check for user meta data at Login
On my website, users have a meta data attribute that is set to either true or false depending on whether they have confirmed their email address or not. I'm trying to not let them log in if they have ...
2
votes
1
answer
1k
views
Query wp_usermeta alongside wp_users
I want to use the WordPress query functions and no external plugins for the task. Here is what I have so far:
add_filter('user_search_columns', 'user_search_columns_bd' , 10, 3);
function ...
2
votes
1
answer
3k
views
Upload files programmatically to users
i'm using pods plugin to add new custom fields to user so i added 4 files custom fields and then trying to upload files to this fields from registration page and create new user but when i upload the ...
2
votes
2
answers
1k
views
How to get top 10 user is based on user meta value
I'm trying to get top 10 users in my wordpress blog based on user meta value.
I've tried few methods & finally able to get just top one user using below wpdb query. But clueless, how we can get ...
2
votes
1
answer
7k
views
How to add country drop down menu to the user profile?
I've added this code snippet to my functions.php
function my_new_contactmethods( $contactmethods ) {
$contactmethods['country'] = 'country';
return $contactmethods;
}
add_filter('...
2
votes
1
answer
6k
views
Extra User Profile Field Upload File / Image
I have been following the following tutorial to try and an upload form to the user profiles. http://www.scribd.com/doc/81666407/Add-and-Remove-WordPress-User-Profile-Fields-and-Display-Them-Within-...
2
votes
3
answers
3k
views
get_user_meta Short Profile Section
Ok so i have added a custom field into the users edit profile page where they can add a link to a url of an image they want. I am currently using this for contribitors and above but i also have a ...
2
votes
1
answer
3k
views
Delete user from frontend
Hi I am working on a frontend admin where a user must be able to delete his account. current_user() is a custom made function of me that retrieves the user meta data.
Does anyone know how I can make ...
2
votes
1
answer
382
views
Querying Email Addresses for a List of Users with Same Last Name?
I have a site with many users and many of them have the same last name. I want to get the emails of all the users with the same last name (IE: Smith) that has a post related to a particular taxonomy ...