I’ve looked at the API page and I don’t see anything about getting a list of user ids. I would like to get a list of user ids of users who have paid memberships at level 1. How can I do that?
Get filtered list of userids
Follow these steps:
- Go to “Users” page
- Click your “Level 1” link (may be named differently, depends of your settings for level names)
- Save that page as a file
- Open that file with Word text processor or clones, or any text editing software that can edit HTML file
- Copy the column with IDs to your clipboard
- Paste it anywhere you need it, that is the list you need. Can paste in a text editor and reformat it.
What I’m asking for is something to get such a list dynamically. I don’t want to have to update the list manually every time a user is added. Surely there must be code or a shortcode that can list the members and filter them by user level .
There is if you have the Pro version. See this: https://s2member.com/kb-article/s2member-list-shortcode-documentation/
That’s nice, but how can I design the results based on the data? I need to add my own links to some custom pages to the results. I don’t see how to do that with those shortcodes. For example
/profile?userid=55
Peter, this is the sort of forum thread that I hate.
You asked for one thing, which Krum gave you. Then you modified your request to ask for something slighly different, and I gave you that. Now you’re asking for something else again!
We aren’t mindreaders.
Can you please explain precisely what you want to do – perhaps even start a new thread – and then someone might know how to answer to your satisfaction.
I hope you don’t mind, I am going to answer my own question.
I want to get some userids so I can create a page with profile links based on the user ids. I want to limit the ids to users who are s2Members level 1.
This does it:
$args = array(‘role’ => ‘s2member_level1’,‘fields’ => array(‘id’));
$user_query = new WP_User_Query( $args );
// User Loop
if ( ! empty( $user_query->results ) ) {
foreach ( $user_query->results as $user ) {
$userids[]=$user->id;
}
} else {
echo ‘No users found.’;
}
$userids now has all the ids that are level 1.