Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I am currently using a plug-in called Wishlist member. It allows you to create membership levels in WordPress. I want to be able to display different content on a page depending on if the user is added to two levels.

Am using the code of "Bainternet":

// get the current user level from WP more important is global $user. $user = wp_get_current_user();

// Get user levels from WishlistMembers $levels = WLMAPI::GetUserLevels($user->ID);

//then run the check for the level you want like this:

if(in_array('silver', $levels)){

// PRINT OUT THE silver LEVEL stuff here }

elseif (in_array('gold', $levels)){

// PRINT OUT THE gold LEVEL stuff here }

which works perfectly if the user is one level. If the user is added to two levels then how to use the above code? Please assist.

Regards,

Raghav.

share|improve this question
    
Is there anybody to assist me? Please. –  Raghav Feb 28 '13 at 13:17
    
Looks like it should work. Does it work for a user who's only in gold, and also for one who's only in silver? Also, what happens (what output do you get) when the user is in both levels? –  jfacemyer Feb 28 '13 at 14:05
add comment

2 Answers

There was a plugin that was available to wishlist insider member called Wishlist Shortcodes Plus.

You can buy this plugin now but you need to register to wishlist insider community first.

If you want to read a review we made several months ago on this plugin at:

http://wishlistmemberplugins.net/wishlist-shortcode-plus

share|improve this answer
add comment

If you're running the latest version of WishList Member, it now has built-in API functions for stuff like this. Using those, you'd do this:

wp_get_current_user();

$gold_sku = 123456789;
$silver_sku = 987654321;
$user_id = $user->ID;

if ( wlmapi_is_user_a_member($gold_sku, $user_id) ) {
     //Do gold stuff here
} elseif ( wlmapi_is_user_a_member($silver_sku, $user_id) ) {
     //Do silver stuff here
}

If want to check that they belong to BOTH levels, do this:

if ( wlmapi_is_user_a_member($gold_sku, $user_id) && wlmapi_is_user_a_member($silver_sku, $user_id) ) {
     //Do gold AND silver stuff here
}

If you want to check that they belong to EITHER level, do this:

if ( wlmapi_is_user_a_member($gold_sku, $user_id) || wlmapi_is_user_a_member($silver_sku, $user_id) ) {
     //Do gold AND silver stuff here
}

You can check the Codex for this function here:

http://codex.wishlistproducts.com/function-reference-wlmapi_is_user_a_member/

share|improve this answer
    
Thanks John! I would use that would let you know. –  Raghav Mar 5 '13 at 9:23
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.