wp_get_current_user Not working
wp_get_current_user Not working
wp_get_current_user Not working
If I understood your question correctly, you want to display this data on a page on front-end. In this case you can either create a page template in your theme folder OR create a shortcode in functions.php. Here is a quick shortcode that may help. add_shortcode(‘currentuser’, ‘shortcode_current_user’); function shortcode_current_user($atts){ ob_start(); $current_user = wp_get_current_user(); echo ‘<table>’; … Read more
First get the data $data = get_user_meta( $user_id, ‘service_name’, true); You find an array of all entries in $data. You can do it this way: <input type=”checkbox” name=”service_name[]” value=”Architecture” <?php echo in_array(‘Architecture’, $data) ? ‘checked’ : ”); ?>>Architecture<br> Untested, but should work.
This how my stored data function is for this meta group and get data stored $certification = array( ‘course_id’ => $certificate_id, ‘course’ => $certificate, ‘date’ => $date, ‘instructor’ => $certifying_instructor, ‘school’ => $school, ‘last_update’ => date(‘d-m-Y’), ); add_user_meta( $user_ids, ‘certifications’, $certification ); and this get data $users_detail = get_user_meta($user_id); $certificates = $users_detail[‘certifications’]; $n_course_id = array(); … Read more
Eventually came to a solution in case anyone needs it: function mb_get_user_meta_values( $mb_user_meta_key ) { if( empty($mb_user_meta_key) ) return; $mb_get_users = get_users( array( ‘meta_key’ => $mb_user_meta_key ) ); $mb_user_meta_values = array(); foreach( $mb_get_users as $mb_user ) { $mb_user_meta_values[] = get_user_meta( $mb_user->ID, $mb_user_meta_key, true ); } $mb_user_meta_values = array_unique( $mb_user_meta_values ); return $mb_user_meta_values; } Then I … Read more
I’m not entirely clear on what you’re trying to do, but it seems you want to pass the user’s email address via a query string and determine the user by that. You can get the user’s ID for writing user meta values from the email value. Use the function get_user_by() to retrieve the user object … Read more
How Can I Display the Last Modified Date for User Profiles on WordPress?
I’m sure there are more sophisticated ways to debug the queries, but I’m not aware of them. So usually when I need to debug WP queries I use either Query Monitor or Debug Bar (with Slow Actions addon) plugin, which can be found on the wordpress.org plugin repository. These plugins help you trace which functions … Read more
I figured it out… $meta_value = get_user_meta( $atts[‘owner’], $meta_key, true ); $store_numbers = array(); foreach ($meta_value as $store_number) { $store_numbers[] = ‘shop’.$store_number; } $usernames = $store_numbers;
You can try below snippet of code. i have develop shortcode you can take reference from it. function current_user_data_func( $atts ) { extract( shortcode_atts( array( ‘metakey’ => ”, ‘user_field’ => ”, ), $atts) ); ob_start(); if(is_user_logged_in()) { $current_user = wp_get_current_user(); $c_user_id = $current_user->ID; if(!empty($metakey)) { $value = get_user_meta( $c_user_id, $metakey, true); echo $value; } if(!empty($user_field)) … Read more