Filter WooCommerce Orders query with user meta data

I see 2 possible ways: 1) Using your WP_User_Query in a WC_Order_Query with the customer_id argument this way: // Users query $user_ids = (array) get_users([ ‘role’ => ‘customer’, ‘number’ => – 1, ‘fields’ => ‘ID’, ‘meta_query’ => [ ‘relation’ => ‘OR’, [ ‘key’ => ‘unsubscribed’, ‘compare’ => ‘!=’, ‘value’ => 1 ], [ ‘key’ => … Read more

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