I’m using Wishlist Member plugin and I’m building a function which compares user_levels and post_levels, but I can’t get my function to work:
check_user_access($userid, $postid){
// get user_levels
$user_levels = WLMAPI::GetUserLevels($userid);
// get the post levels
$post_levels = WLMAPI::GetPostLevels($postid);
// Compare user_levels with post_level
$result = array_search($user_levels, $post_levels);
if ($result === false) {
return false;
}
else {
return true;
}
}
Maybe because $user_levels is an array?
Try something like:
I think this is what you’re looking for. This will let you find if a user can access a post, page, or category. This uses the new API functions in the latest versions of WishList Member and accepts ‘post’, ‘page’, or ‘category’ as the $object_type parameter.
You can see the documentation for all the used functions at http://codex.wishlistproducts.com
First of all, you are using the old Wishlist Member API, try using the new one it’s much more comprehensive. You can find the new API at: http://wishlistproducts.com/api/api2/
The returned variable are object to find out their content use
var_dump
for debugging then just get the required information.