Create a dropdown list displaying users meta data
Create a dropdown list displaying users meta data
Create a dropdown list displaying users meta data
No, not correct – get_user_meta() returns meta data based on the $user_id parameter you provide. You can combine it with get_current_user_id() to check if an user is logged in and than – if so – get the post meta. E.g. like this: $curr_user_id = get_current_user_id(); // the value is 0 if the user isn’t logged-in … Read more
How to toggle delete/update user meta values?
You are using get_currentuserinfo in a wrong way because you are passing parameters that this functions doesn’t accept and you expect that the functions return directly what you want. get_currentuserinfo doesn’t accept any parameter, returns a WP User object and require the global $current_user var. Anyway, I prefer to use wp_get_current_user() in order to avoid … Read more
All of this can be done using WP_User_Query: $users = new WP_User_Query(array( meta_query( array( ‘key’ => ‘login_status’, ‘value’ => ‘0’ ), array( ‘key’ => ‘active_code’, ‘value’ => ‘3f7431e226893f16cbe44424850d00ad’ ) ) )); This will return a list of users that meet your requirements. Then you can get the ids like so: $user_ids = wp_list_pluck( $users->get_results(), ‘ID’ … Read more
The Active Directory Integration plugin causes this. I’ve posted a bug report and will perhaps contribute a fix.
get user role value as a string from wp usermeta table into custom script
Use PHP explode function and convert string into array using a delimiter | then you can use foreach loop. Example:- $str = get_the_author_meta(‘my_pet’, $author_id); $pets_array = explode(‘| ‘, $str); if (is_array($pets_array)) { foreach ($pets_array as $pet) { echo $pet; echo ‘somtext’; echo ‘<br />’; } }
You can store the user meta in a variable and check if the variable is empty or not, like below- $args = array( ‘role’ => ‘subscriber’, ‘meta_key’ => ‘user_designation’ ); // The Query $user_query = new WP_User_Query($args); // User Loop $u_meta_array = array(); if ( !empty($user_query->results) ) { foreach ( $user_query->results as $user ) { … Read more
WordPress provides a function get_users which display all the user detail and which field you want just pass in the ‘fields’ array. $users = get_users( array( ‘fields’ => array( ‘ID’,’user_login’, ‘user_email’) ) ); foreach ( $blogusers as $user ) { $user_work = get_user_meta( $user->ID, ‘user_work’, true); $user_street = get_user_meta( $user->ID, ‘user_street’, true); $user_state = get_user_meta( … Read more