0

See image of the table here: [1]: https://i.stack.imgur.com/KjWIQ.png

How do I show data from 'designs_save_user_list' of all user_id that contain 'account_parent' and with the same number in the meta_value?

I'm only able to see the data of a user, but I want to see everyone who has the same number in the account_parent

the current code is:

if(is_user_logged_in()){
        $user_ID = get_current_user_id();       
        $get_designs_list = get_user_meta($user_ID, 'designs_save_user_list', true);
Rafael
  • 1
  • See: [How to SELECT based on value of another SELECT](https://stackoverflow.com/q/9970495/11987538) - in short: you will have to use a custom query, since WooCommerce doesn't provide built-in functions for your kind of question, or you would have to combine built-in functions which would end up with a 'dirty' result since it would be too extensive compared to a compact and focused SQL query – 7uc1f3r Jun 02 '22 at 08:36
  • _"but I want to see everyone who has the same number in the account_parent"_ - so get the value for the current user first, then use `get_users` to get all users with the same value. Loop over them, and call `get_user_meta` for each one ... – CBroe Jun 02 '22 at 08:43

1 Answers1

0
       if(is_user_logged_in()){
                $user_ID = get_current_user_id();       
                $account_parent = get_user_meta($user_ID, 'account_parent', true);
                if (isset($account_parent) && $account_parent == 2 ){
                    $get_designs_list = get_user_meta($user_ID, 'designs_save_user_list', 
                    true); 
           }
    }

check this code if its work for you

Nitesh
  • 101
  • 3
  • Hello Friend! thanks for the reply! This returned me the same data as the current logged in id, I also think adding the "== 2" will only return data for user "2", but I need to view the user with the id it contains in the parent account. did you think of something different? – Rafael Jun 03 '22 at 01:38