latest stable versions: v150827 (changelog)

Old Forums (READ-ONLY): The community now lives at WP Sharks™. If you have an s2Member® Pro question, please use our new Support System.

MySQL – calling multiple member levels

Home Forums Community Forum MySQL – calling multiple member levels

This topic contains 5 replies, has 3 voices. Last updated by  Jason (Lead Developer) 3 years, 12 months ago.

Topic Author Topic
Posted: Saturday Jan 5th, 2013 at 11:28 am #36273
Epix Media
Username: epixmedia

Hi all, I’m creating another searchable member list for someone and need to know the best way to call back multiple member levels as they have 16 levels.

This is my current query for listing all members:

$users = $wpdb->get_results ("SELECT DISTINCT(U.user_id) as `ID`
	FROM " . $wpdb->usermeta . " AS U
	inner join " . $wpdb->usermeta . " as UML on U.user_id = UML.user_id 
	inner join " . $wpdb->users . " as WU on U.user_id = WU.ID
	WHERE UML.meta_key = '" . $wpdb->prefix . "capabilities'
		AND UML.meta_value REGEXP '.*\"".s2member_level16."\";s:[0-9]+:\""."1"."\".*'
		ORDER BY WU.user_nicename
		LIMIT ".$start.", ".$limit."");	

Is it possible to pass perhaps a comma delimited list of member levels in to the regular expression somehow??

Any advice welcome!!

Thanks :)

Zoe

  • This topic was modified 3 years, 12 months ago by  Eduan. Reason: Put code in between code tags

List Of Topic Replies

Viewing 5 replies - 1 through 5 (of 5 total)
Author Replies
Author Replies
Posted: Tuesday Jan 8th, 2013 at 6:23 am #36564
Epix Media
Username: epixmedia

can anyone help please?

Posted: Tuesday Jan 8th, 2013 at 6:02 pm #36632
Eduan
Username: Eduan
Moderator

Well, although I’m not experienced with MySQL.

I’m thinking, maybe you could have an array or an associative array with all the levels? That’s my two cents, I’m afraid I can’t offer anything else. :)

Also, I put the code in between code tags, otherwise WordPress will automagically transform the quotes into curly quotes and stuff. :)

– Eduan

Posted: Saturday Jan 12th, 2013 at 3:41 am #37090
Staff Member

Thanks for the heads up on this thread :-)

@ Epix Media

You can use this s2Member global variable to determine
the number of Membership Levels that are currently configured for any given site.

$GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["levels"]

That being said, you could simply design your REGEX pattern to consider ANY numerical value, so that it would pickup on any meta key that matches what you’re looking for, regardless of Membership Level. So instead of writing s2member_level16, you would write s2member_level[0-9]+, which would work for s2member_level0, or even s2member_level239822423, if god forbid someone ever did that! :-)

See: http://www.regular-expressions.info/charclass.html

Posted: Saturday Jan 12th, 2013 at 4:50 am #37097
Epix Media
Username: epixmedia

Fab thanks Jason!

Not sure if you’ve changed something on the forum but I also received a reply notice email for the first time!!!

Cheers :)

Zoe

Posted: Sunday Jan 13th, 2013 at 3:51 am #37221
Staff Member

That’s great! Yes, we did switch to a new, more reliable SMTP server for outgoing messages from our forum. I’m thrilled to hear that. Thanks for the feedback :-)

Viewing 5 replies - 1 through 5 (of 5 total)

This topic is closed to new replies. Topics with no replies for 2 weeks are closed automatically.

Old Forums (READ-ONLY): The community now lives at WP Sharks™. If you have an s2Member® Pro question, please use our new Support System.

Contacting s2Member: Please use our Support Center for bug reports, pre-sale questions & technical assistance.