How do I create a column in Users list and display user data from custom registration field

Use the following code to add new column and show data properly. function add_user_columns_hospital( $column ) { $column[‘hospital’] = ‘Hospital’; return $column; } add_filter( ‘manage_users_columns’, ‘add_user_columns_hospital’ ); function modify_user_table_row_hospital( $val, $column_name, $user_id ) { switch ($column_name) { case ‘hospital’ : return get_the_author_meta( ‘user_registration_hospital’, $user_id ); default: } return $val; } add_filter( ‘manage_users_custom_column’, ‘new_modify_user_table_row’, 10, 3 … Read more

How do I display a user’s previous orders as a select box option on a product?

You can try something like this: add_action( ‘woocommerce_before_add_to_cart_form’, ‘add_list_completed_orders’ ); function add_list_completed_orders() { // get orders $orders = wc_get_orders ( array ( ‘status’ => array( ‘wc-completed’ ), ‘type’ => ‘shop_order’, ‘limit’ => -1, ‘return’ => ‘ids’, ‘customer_id’ => get_current_user_id(), ) ); if ( ! empty( $orders ) ) { // set value options $options=””; foreach … Read more

WordPress User Meta & ChromePHP or other way to debug/view php variables

In this code: if ($gender == ‘his_Male’) { $wpgender=”Male”; } elseif ($gender=”her_Female”) { $wpgender=”Female”; } else { $wpgender=”Other”; } You’re not comparing $gender to ‘her_Female’, you’re setting it to ‘her_Female’: } elseif ($gender=”her_Female”) { You should be using == or === (preferably ===, the difference is documented here). Your second question is really a chrome-php … Read more

In what part of the WordPress core does the users table and usermeta table get joined?

I’m not 100% what you are asking, it seems like several questions? But here goes: $meta_value = get_user_meta($user_id, $key, $single); For example: $first_name = get_user_meta($user_id, ‘first_name’, true); As for adding hooks I think this answer might be what you are looking for? How To Add Custom Form Fields To The User Profile Page? UPDATE Based … Read more

How to display specific posts with WP_Query?

Could be because you are passing an array of array try this: <?php $my_query = new WP_Query(); $my_query->query(array( ‘post__in’ => $curauth->user_favourite_post)); while ($my_query->have_posts()) : $my_query->the_post(); ?> <h3><a href=”https://wordpress.stackexchange.com/questions/27808/<?php the_permalink(); ?>”><?php the_title(); ?></a></h3> <?php endwhile; ?>

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)