WordPress does provide you with the ability to save meta data for users, so you could just store the agent’s user id in a meta field of his subscribers, like update_user_meta( $user_id, "agent", $agent_id )
.
You can then query those users with the WP_User_Query’s meta_query, e.g.
$agents_subscribers = new WP_User_Query( array(
'meta_key' => 'agent',
'meta_value' => $agent_id
) );
Related Posts:
- Modify custom Users Manage page
- How to Save Different Usermeta Fields According to User Role?
- Ability to only view (not edit) other user’s personal profile information
- how to make a custom field readonly or disabled by user role?
- Change the functionality of wordpress users module in admin
- Changing starting number of User ID
- Some data of one custom user profile is erased when I update another custom user profile
- Backup the Database and Restore from the Backup?
- How to update the delete user confirmation form?
- How to add checkbox and radio button in Profile Page
- How do I properly format the user_role array?
- Can I use $wpdb for my custom tables in the WordPress database?
- Extra User Profile Field Upload File / Image
- What Is The Difference Between suppress_errors() And hide_errors() in $wpdb?
- Prevent WordPress from loading comments
- Suggestions for WPMU Migration (advanced)
- Retrieve and display data from custom db table in admin area?
- How to find if a post with custom_field == X exists?
- Custom search page and search by title, content and tag
- Can I create front-end editable user profile pages with WordPress? How do I do it?
- Set user loggin status?
- How can I add data to a custom column in the Users section of the wordpress backend?
- user-new.php less detailed after WP3.1; how to revert?
- Unique User Account Number + Displayed Via Shortcode
- What’s the proper way to use a custom table? [closed]
- How to retrieve the value stored in a multi-dimensional array and SUM the entries?
- Last time a user logged in
- Remove the deleted users avatar from list
- User Roles Not Sticking
- How to add local users to wordpress without email password?
- Adding a Table to the wordpress database
- Updating Custom WordPress User Meta Field via REST API
- How to pass external variables to the wp_new_user_notification_email filter?
- How can I allow access to multiple users, using the same login, at the same time?
- WP Northwind for Theme Development?
- Function to allow “Anyone can register”?
- Make custom user table column filterable
- How to show a gloabl message on a user profile page (in back end)?
- Add ‘Creator’ User Meta when adding user
- Follow me for WordPress blogs (multi-authors)
- Fastest way to get the comment and ping total count for a post
- I want to submit multiple users if checkbox is checked
- Change the Labels of Users to Customers in Admin
- Add custom profile field only for site admins?
- $wpdb->replace: WHERE?
- custom user role wordpress – grant guest access to edit.php without insert/update/delete
- Allow guests to use WP Customizer but disable save button
- How to use default WP form elements to interact with custom DB table?
- Users can only view their content from the front end
- Custom Role with Own Page Edit Capability
- List top 5 authors with most posts
- Multi-site User Sessions
- Problem with custom user meta field
- Customizing Users in Admin Area
- How to stop displaying the Id without losing the functionality
- Restrict access to non-wordpress section of site with user roles?
- Applying WP-cli Search & Replace to Static SQL Dump File
- How to make wordpress use a non-wordpress users table?
- How to hide user profile fields based on the role of the viewed user?
- Is there a possiblity to replace profile image gravatar with custom user images
- Allow multisite admins only to create users with one specific user role?
- Setup database structure with books, authors, languages etc. for publishing house [closed]
- Add table to WordPress database
- how to add wp-user fields to front-end form
- Custom Database Table and foreach
- how or where wordress collect unlogged user session
- Need help with creating a searchable user data by name or specific number like ID
- optimal taxonomy or custom post types
- No plugin populate user information in to form
- Use a custom page with dynamic content as a user profile page
- how to create user profile pages and display them based on users roles
- Invitation link to a site in multisite network does not work?
- Migrating my site to a new domain does not keep any changes made in customizer
- New Page/Post Screen Opens an Existing Post
- WP_User_Query Search Multiple Keywords from a Multi-Select Field?
- Advice on how to structure a custom plugin
- Custom roles and capabilities media not work right
- How to have differents sites share the same tables of DB?
- Need help with drop down list on the profile
- Custom Form Input not saving to Database
- Show comments based on user role in front end
- How to display all post from the same current usermeta
- Accountless password generation
- Highlight specific user with custom field value
- Disallow “contributors” to edit their own posts once they’ve been set to “Pending Review”
- Add several fields from different tables to post, fields per post are in same row of table
- Get id from database
- Where should I put this custom data?
- Show WP content on different PHP Sites
- How to connect database table to each registered wordpress user.
- Database custom table issues – incorrect result displayed
- Custom search by several options send on form not works
- User registration add user ID?
- Accessing + retrieving custom database in WordPress
- How to create functions that affect only a specific user
- Security Issues with custom user role or changing core role capabilities?
- Create users via PHP
- Use wp_login_form function to login with a custom user table?
- How to give different user access to different people?
- Changes to code not displaying