I have created a custom registration page, whereby a person will receive a code from another user and type in a code upon registering. If the code matches, i need the user who has just registered to become related to the user who they received the code from. Note i am saving these codes in a custom plugin table.
So you will have a one to many relationship, where a user can have many sub users. If possible i need to be able to extend that further so that a sub user could also have many sub users. So the first relationship and my priority right now would be:
USER
|
SUB-USER
I would then like to be able to do this:
USER - A
|
SUB-USER B -------
| |
SUB-USER C SUB-USER D
User B is related to User A. User C and D are related to B.
I know we can make use of the and Update User Meta and query these relationships with the following query, i would just like some advice about creating this sort of relationship going forward.
$users_sub_users = new WP_User_Query( array(
'meta_key' => 'user',
'meta_value' => $user_id
) );