if I were you, I would use the wp_usermeta table. it is possible to add information to this table easily:
add_user_meta(NEW_USER_ID, "PARENT_USER_ID",USER_ID,true);
USER_ID: the Id of top level user, (In your case id of user A)
“PARENT_USER_ID”: some key that you could search and find result based on
NEW_USER_ID: The Id of sub_user
true: To let many user be sub user of the same user
for instance if USER A id is 41, and the Id of new user (which is B) is 82 your code look like:
add_user_meta(82, "PARENT_USER_ID",41,true);
then you can search for all users which their PARENT_USER_ID is user_id (in our example 41) and then you will get all sub users for that user.
sample query:
$user_query = new WP_User_Query( array( 'meta_key' => 'PARENT_USER_ID', 'meta_value' => '41' ) );
Related Posts:
- last_name + first_name orderby with meta_query [solved]
- wp_user_query with meta_value_num for leaderboard
- WP_User_Query with combined meta query – not working?
- WP_User_Query with meta_query array relation ‘OR’
- WP User Query fails when searching meta queries and search columns
- How to pass user meta_key and meta_value (values as array)
- WP_Query ordered by meta_value_num doesn’t fetch posts without this meta field
- WP User Query Issues
- meta query based on month regardless of year
- meta_query in WP_User_Query not working – returns every user, not just users where key & value matches
- how to search all user meta data that have value like “vivek”
- wordpress meta value compare between two date
- get_users with Serialized Custom Meta Value
- How do I echo all users’ display_name and their meta_value who have a certain meta_key?
- Issue with user meta_query
- How to do WP_User_Query for Nested Array value Inside Nested Array field
- get_user can’t read variable
- Query for user roles and their skills
- WP User Query with meta queries
- How to fetch WP_User_Query with multiple role arguments [duplicate]
- Display Users from two roles in one list
- Meta query terribly slow
- meta_query sorting by 2 keys
- How to handle optional end date in compare clause in meta_query
- Using meta_query on pre_get_posts to exclude a particular meta_key value
- Wp_User_Query not sorting by meta key
- Check if WP_User_Query ‘include’ is empty
- Best practice – Meta Query vs. post_clauses for “left join” ordering
- Combining Meta_Query key values for one array
- Different page parameters inside query
- LIKE %…% Meta Query
- Documentation for post meta
- Arrange Posts By Date In Order Of Closest To The Current Date
- Custom Upcoming Events List for Events Manager Plugin
- How to use meta_query to check if a meta field has something set?
- Edit post_content on posts with Featured Image
- meta_query for a string inside a meta field containing a comma-separated list
- Use both meta query and tax query
- meta_query, number comparison, not quite working as it should
- Query posts only if meta_value is not empty
- meta_query compare=’!=’ with multiple custom fields
- Query posts with numeric meta values within a given range
- Parent User and Child User – relate users
- Fastest way to do meta query when I don’t need the actual posts, and just need post_id?
- meta_query not working on live site
- How do you get Posts by multiple meta_keys and meta_values with the Rest API V2?
- Meta_query on same meta key, with diffrenct values
- Meta query with regular expression does not work
- Why get_users() not working on the admin backend?
- Passing args to WP_User_Query am I using meta correctly?
- Help on multiple meta_query
- Meta query – How to display a null meta key
- pre_get_posts and set
- How to pull all the contributer users records and order by Designation (which is users meta data)?
- How to use orderby with meta_query?
- Reduce number of SQL queries inside WP_Query loop to fetch author data
- ACF: How to get users with a ACF flexible content subfield with a specific value AND layout?
- Extend meta query arguments
- get_posts( $args ) return empty data
- how to get post meta where value is an array of key value pairs
- Search users with custom meta data
- Meta Query Based on Month Range
- WP JSON API meta_query not working
- Ordering custom posts by meta field date
- How to: get_user_meta – BuddyPress [closed]
- meta_query displays all results and none, my query is wrong
- How to properly escape values in meta query
- Fetch custom post related to a User
- How to Ordering by user meta
- Use meta_query in args for relationship
- User query – getting values for custom meta keys/fields
- meta_query compare “=“ returns nothing when it seems it should
- Order resultset by configured value and then list all the rest
- Query users and count totals based on meta values
- How to get an archive page meta?
- Querying terms with calculations based on term meta data, sql vs. get_terms
- How to select meta key in custom database query
- WP_User_Query Orderby Not Working
- WordPress meta query not working
- Get meta_value from GDRating
- Unusual high query of user meta data
- meta_query orderby sort multiple keys
- Why does this incorrect pre_get_posts meta_query work for sort order?
- How to sort custom posts including null meta-values in admin columns with meta_query?
- Exclude Posts Using Meta Query and User Meta
- get posts meta query returning the latest post if no meta key found
- Search using specific meta fields only (excluding post title and content)
- How to get meta value based on latest post id with group by term name
- How can I include user meta information in the resulting array of a WP_User_Query?
- Meta query not returning results even though the sql contains the information
- Multiple Queries with meta_query
- Get foreach for meta_query value
- list or get meta_key where meta_value is ‘something’
- order by meta_key [duplicate]
- Shortcode for displaying the user’s first name?
- WordPress Meta Query very slow with NOT EXISTS comparison
- ACF meta_query field treated as “0” resulting in false negative search when testing ranges
- Is it possible to customize meta query in this way?
- Ordering WP_Query results by second meta_key
- How making a new search box in admin post table working on a specific column