Query Nickname rather than Display Name in custom Woocommerce plugin

I had a similar problem and solved it similar to this: add_filter(‘pre_user_display_name’,’default_display_name’); function default_display_name($display_name) { if ( isset( $_POST[‘billing_first_name’] ) ) { $display_name = sanitize_text_field( $_POST[‘billing_first_name’] ); } return $name; } I think, the new woocommerce changes the disyplay_name on every checkout to First_Name Last_Name. With the ‘pre_user_display_name’ you can change your own way.

How can get all users by current user meta?

You can achieve this using get_users function and its meta_key argument as displayed below. $users = get_users(array( ‘meta_key’ => ‘blocking_users’, )); var_dump( $users ); To retrieve it for current user and print it, please use below code. $user_id = get_current_user_id(); $key = ‘blocking_users’; $single = false; $blocking_users = get_user_meta( $user_id, $key, $single ); echo ‘<p>The … Read more

Comapare get_user_meta value

You can use meta_key or meta_query to fetch users where get_user_meta() ‘val’ == 1 Option 1: $users = get_users(array( ‘meta_key’ => ‘val’, // your_meta_key ‘meta_value’ => ‘1’, // value you want to compare ‘meta_compare’ => ‘=’, )); Option 2: $args = array( ‘meta_query’ =>array( array( ‘key’ => ‘val’, //your_meta_key ‘value’ => 1, // value of … Read more

Problems using ‘add_role’

You can pass the user’s role directly to wp_insert_user(). First, you can try to add your custom role to the WP_Roles object, then pass the custom role to the user properties: // Add custom roles only once to avoid unnecessary database calls. // It is usually done during plugin activation. register_activation_hook( __FILE__, ‘cyb_add_roles’ ); function … Read more

Front-End User Profile

UPDATE: As mentioned in the comments, you might want to learn how you do things like create meta boxes and do a file upload in WordPress without using a framework like CMB2 first. However, as a seasoned WordPress developer, I have found that using CMB2 greatly increased my productivity. I highly recommend using CMB2 to … Read more

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