Page 1 of 1
if user level 1
Posted:
December 5th, 2011, 4:44 am
by epixmedia
Hi all, I know I've seen the code on here somewhere on the forum but I just can't find it!
Its for saying
if(userlevel= s2member level 1) {
//do this
}
in my php code...
Cheers
Zoe
Re: if user level 1
Posted:
December 5th, 2011, 8:40 am
by Eduan
Go under
WP Admin -> s2Member -> API / Scripting -> Advanced/PHP Conditionals and see if that's what you mean.
Hope this helps.
Re: if user level 1
Posted:
December 5th, 2011, 9:47 am
by epixmedia
Thanks - forgot that was there, it was: if (user_is($user_id, "access_s2member_level1")) I needed!
Re: if user level 1
Posted:
December 5th, 2011, 9:50 am
by epixmedia
ok, its not quite going to work how I imagined. What I really need to do is query the database to only bring back members that are level 1 or higher! My current query is
$users = $wpdb->get_results ("SELECT `user_id` as `ID` FROM `" . $wpdb->usermeta . "` WHERE `meta_key` = '" . $wpdb->prefix . "s2member_custom_fields' AND `meta_value` REGEXP '.*\"".display."\";s:[0-9]+:\"".Yes."\".*' ORDER BY `meta_value` ASC");
Where is the member level stored?
Cheers,
Zoe
Re: if user level 1
Posted:
December 6th, 2011, 4:49 am
by epixmedia
For anyone else looking to do this, I've altered my code to use inner joins to enable me to reference multiple custom s2 member fields:
$users = $wpdb->get_results ("SELECT DISTINCT(U.user_id) as `ID`
FROM " . $wpdb->usermeta . " AS U
inner join " . $wpdb->usermeta . " as UMF on U.user_id = UMF.user_id
inner join " . $wpdb->usermeta . " as UMS on U.user_id = UMS.user_id
inner join " . $wpdb->usermeta . " as UML on U.user_id = UML.user_id
WHERE UMF.meta_key = '" . $wpdb->prefix . "s2member_custom_fields'
AND UMF.meta_value REGEXP '.*\"".display."\";s:[0-9]+:\"".Yes."\".*'
AND UML.meta_key = '" . $wpdb->prefix . "capabilities'
AND UML.meta_value REGEXP '.*\"".s2member_level1."\";s:[0-9]+:\""."1"."\".*'");