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 the membership level of the viewing user. Something like this -

<?php global $current_user; get_currentuserinfo(); 
if ($current_user->user_level == 10 ) { ?>
  Admin Stuff (In my case I left this blank)
<?php } else {   ?>
  Stuff Seen By Visitors
<?php } ?>

But not just for the admin. I have found that this plug-in create creates these for each member level "wpm_access[1296320588]" and "wpm_level[1296320588]". Any ideas on how I could check the current user against this?

Thanks!

share|improve this question
    
Giblette - For "wpm_access[1296320588]" and "wpm_level[1296320588]" what context are they? Are they actually array variables $wpm_access and $wpm_level? If arrays, what do those elements contain? What does 1296320588 represent? –  MikeSchinkel Jan 29 '11 at 21:33
add comment

2 Answers 2

up vote 3 down vote accepted

there is a lot of discussion about this in wishlisMembers support forum but the developers over there ignore it. Any way try this:

// 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
}

Simple.

share|improve this answer
    
This works perfectly! Thank you!! Yeah I had tried using their support forum but never heard anything back. ;) –  Red Jan 30 '11 at 22:43
add comment

Sorry for not replying to the previous answer, but I just do not know how. Thanks Bainternet for your answer, but it has, however, a huge flaw. Problem is if you have a Cancelled / Ended membership in WL Member, it will still show up in the $levels array. This ends up in being a huge security flaw. How to fix this?

EDIT TO THIS POST: Found how to solve this (WLMAPI::GETUserLevels documented over here http://wishlistproducts.com/api/api1/ ) You will need to set the int $cancelled to 1 not to get the cancelled subscriptions in your array.

EDIT TO THIS POST AGAIN: I appologise, the error I was having was related to ended subscriptions, not cancelled ones. The default parameter of $canceled is 0 and that means do not return cancelled subscriptions which is the general intended behavious. Last night I had too much code that's why i started to speak wrong. Too bad you cannot set the function not to return ended subscription levels.

share|improve this answer
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.