i dont know how to achieve this in query arg.
This is because it cannot be done using just arguments. No option for role is listed in the order/orderby parameter docs. There is no option to sort by user role in WordPress.
Instead, you’re going to have to query for all gold role users, grab their user IDs, then query for all free users, grab their user IDs, then query for the users with those IDs in a third query.
Notes:
- This will not scale, if you have a lot of users, this will grind the site to a halt, and the page may not finish loading
- You will have to throw away your pagination code, and re-implement it to work off of the array
- You’ll need to figure out which IDs in the array are for the current page, and slice it accordingly
- You’d need to figure out wether the current page is for gold or free users, or if there’s an overlap and slice the appropriate array to get the IDs
- It would be easier to just have separate archives/lists for gold and free users
- Your code would expose personally identifiable information if it was ever shown to non-employees/staff, making it illegal in numerous countries ( it would violate GDPR in EU states ).