I want to disable user_login field into my CMS. They are register only their email adress. I think to create secret user login by programmatically. I think for accessibility and manageability also I want to use their ID'. For this I want to know last user's ID. I know the unprofessional way of doing this. A way as below, <?php $args = array( 'orderby' => 'registered', 'order' => 'DESC', 'number' => 1 ); $users = get_users($args); $last_user_registered_ID = $users[0]->ID; But …
I know this is not the way u should go, but my customers want it so im looking for ways. Requirement: WP with one DB (3 Domains sale the same stuff) 3 Domains which use this DB (can be more later), this should work with on fly rewriting over hooks user registered should be only able to login in the domain where he is registered, but should be able to register on the other 2 domains with same data. My …
I think I'm missing a step here, but for the life of me I can't see it. I'm trying to display a simple list of users who all have the same role and have the same meta data value for a certain key - namely, teachers associated with a school. Here is my code: <div class="teachers-list"> <h3>Your School's Teachers</h3> <ul> <?php $champion_user = wp_get_current_user(); $school = $champion_user->school; // echo $school just to test it's right.... ?> Your school: <?php echo …
I need to create a search page that will display anything related to the supplied search. i.e. comments containing it, events, posts, CPTs and users with that name. How can I search for users in the site who's first or last name contains the search phrase ?
I need to create a system in which I have 2 types of users: Company User (C) and Employee User (E). I need C to be able to register as many E as necessary and for C users to be able to publish articles that will only be visible to E users, children of C users. I figured it would be possible to do this with meta fields so I created the ACF DAD and CHILD field with Jet Engine …
I am trying to display the current user's ALL comments in a specific page and I'm using this code (uses a shortcode): https://blog.ashfame.com/2011/01/show-recent-comments-particular-user-wordpress/ And have modified it: <?php /* Plugin Name: Show Recent Comments by a particular user Plugin URI: http://blog.ashfame.com/?p=876 Description: Provides a shortcode which you can use to show recent comments by a particular user Author: Ashfame Author URI: http://blog.ashfame.com/ License: GPL Usage: */ add_shortcode ( 'show_recent_comments', 'show_recent_comments_handler' ); function show_recent_comments_handler( $atts, $content = null ) { extract( …
How do I get a list of all users with role = 'Customers' including all the metadata per user, means wp_users + wp_usermeta. Query blow does not generate the wanted results. $query = "SELECT * FROM wp_users INNER JOIN wp_usermeta ON wp_users.ID = wp_usermeta.user_id ORDER BY ID DESC'); "; $data = $wpdb->get_results($query,ARRAY_A); But that list is not correct. It shows each user x times depending on the number of rows in wp_usermeta. How can I filter it? That each user …
I'm having some problems when comparing integer values '>=' or '<=' with meta_queries with the WP_USER_QUERY. Let say I've stored the following meta keys with the meta values below: meta_key meta_value type type1 status active location London min_price 10000 max_price 20000 The query works fine for the meta keys 'type', 'status' and 'location'. But I'm having problems with the 'min_price' and 'max_price'. Below you can find the code I used to retrieve a list of users with the above meta …
I'm trying to create a table with a list of users and it only seems to work when I have it set up like this: $user_report_query = new WP_User_Query( array( 'role' => 'Administrator' ) ); The array I'm trying to use is: $args = array ( 'role' => 'Participant', 'order' => 'ASC', ); Participant is a custom role which has already been set up. I can select the role when creating users from the role dropdown menu. But any time …
My database tables become corrupted so for fixing them I restored data and It shows an error #1067 - Invalid default value for 'user_registered' how can I fix it.
I'm almost done, the code below does everything but display post count for each user broken down into post types, and also I'm like to filter it last thirty days. I'm trying to get the post for each user fr the custom post type 'music'. <div id="top-artist-wrapper"> <?php foreach ( get_users('orderby=post_count&number=5') as $user ) : ?> <div class="top-artists"> <?php echo get_avatar($user->ID, '64'); ?> <div class="artist-name"> <?php echo $user->display_name; ?> (<?php echo count_user_posts( $user->ID, $post_type='music' ); ?> Posts) </div> </div> <?php …
I have a search form, and im trying to have it be able to search both the basic user field (user_email, display_name, etc), plus 1 other custom user meta key called "clinic" heres the argument i have so far $args = array( 'orderby' => 'display_name', 'meta_key' => 'course', 'fields' => 'all', 'search' => $search, 'meta_query' => array( array( 'key' => 'clinic', 'value' => $search, 'compare' => 'LIKE' ) ) ); Also, not sure if i have this set up correctly, …
I am beginner at customizing wordpress but have some experience in PHP coding. I'm struggling to figure out how to display all existing meta keys (custom fields defined by ACF) for all users that have role "author". Default fields display ok, but cannot get values of those meta keys / custom fields. The code below was created with wp generator and manually expanded. I tried here with only 2 default fields (user email and display name) and 2 meta custom …
I'm turning out some subscriber archives and singles (profile pages) in my plugin where I'd also included a 'user-single' template, included via template_include. I'm experimenting however with trimming some of these templates out of my plugin in order to make it use theme templates. I've instead used locate_template( 'single.php' ) to choose the single template from the active theme. I'm not using the global wp_query to turn out my content in this case but the page shows a loop based …
I have a meta_key inside the table usermeta called 'sms_subscriber'. The meta_value for it is their phone number. I want to echo a list of all users who have that field; in other words, a list of each user's name, phone number, and the quantity. The page output might look something like this: SMS Subscribers (3) 1 ben blue +15553335555 2 bob bananas +445557778888 3 jerry johnson +13334445555 I have tried many different queries and have successfully echo an array …
There are many widgets in Elementor which allow using MySQL statements to populate some data field. What I am trying to do is populate a field with a specific user's order data. The problem I am running into is because these Elementor MySQL editors do not allow php I have to get the current user ID, etc... with only valid MySQL syntax. I am very new to developing in WordPress. Should I just grow a pair, move out of my …
I have custom post type Task where I assigned Users as Volunteers. Now I would like to fetch how many tasks assigned to a Volunteer. I am using below code. $users = new WP_User_Query(array( 'meta_query' => array( 'relation' => 'OR', array( 'key' => 'last_name', 'value' => $_POST['search'], 'compare' => 'LIKE', ), ), )); $users_found = $users->get_results(); $names = array(); foreach ($users_found as $user) { $this_users_tasks = get_user_meta($user->ID,'task',false); $names[$user->ID] = $user->display_name.' ('.count($this_users_tasks).')'; } echo json_encode($names); die; But I am getting wrong …
On a site with 12 custom user roles I need to count users with the 'supervisor' custom capability but limited to four specific roles. The following code counts all users with the 'supervisor' capability, but does not limit it to the specific roles: $args = array( 'role' => 'supervisor', //this is a custom capability 'role__in' => array( 'level1', 'level2','level3','level4' ) //these are custom roles ); $user_query = new WP_User_Query( $args ); $supervisors = count($user_query->results);
So, I'm trying to do a query on 'members' based on some inputs from a form using AJAX. The thing is that when searching for a 'role' I get the expected result. But once I try to look for other meta values, the return bring all members in the DB. I tried in a bunch of ways but I either get the result I just said, or I simply get no result at all (even with the role) Here is …