PriMoThemes — now s2Member® (official notice)

This is now a very OLD forum system. It's in READ-ONLY mode.
All community interaction now occurs at WP Sharks™. See: new forums @ WP Sharks™

if user level 1

s2Member Plugin. A Membership plugin for WordPress®.

if user level 1

Postby epixmedia » December 5th, 2011, 4:44 am

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
User avatar
epixmedia
Registered User
Registered User
 
Posts: 59
Joined: November 15, 2011

Re: if user level 1

Postby Eduan » December 5th, 2011, 8:40 am

Go under WP Admin -> s2Member -> API / Scripting -> Advanced/PHP Conditionals and see if that's what you mean.

Hope this helps. :)
Now officially accepting Professional s2Member installations along with Bruce C (a.k.a. Ace).

If you're interested in a Professional s2Member Installation, or a Custom Coding Job, you can send your request here.
User avatar
Eduan
Experienced User
Experienced User
 
Posts: 1154
Joined: August 27, 2011
Location: Taxco de Alarcón, Guerrero, México.

Re: if user level 1

Postby epixmedia » December 5th, 2011, 9:47 am

Thanks - forgot that was there, it was: if (user_is($user_id, "access_s2member_level1")) I needed!
User avatar
epixmedia
Registered User
Registered User
 
Posts: 59
Joined: November 15, 2011

Re: if user level 1

Postby epixmedia » December 5th, 2011, 9:50 am

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
User avatar
epixmedia
Registered User
Registered User
 
Posts: 59
Joined: November 15, 2011

Re: if user level 1

Postby epixmedia » December 6th, 2011, 4:49 am

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"."\".*'");
User avatar
epixmedia
Registered User
Registered User
 
Posts: 59
Joined: November 15, 2011


Return to s2Member Plugin

Who is online

Users browsing this forum: Bing [Bot], Google [Bot] and 1 guest

cron