How to Deal With WordPress Site Members When Working With the Wishlist Member Plugin

How to Deal With WordPress Site Members When Working With the Wishlist Member Plugin

The Wishlist Member plugin is a very popular WordPress membership plugin. It is a high quality plugin with a great deal of functionality to support building and maintaining a membership site. However, the plugin lacks overall support and doesn’t haven enough documented tutorials. The current documentation is available here this page).

The following short instructions were prepared from our own experience after building several WordPress solutions using the Wishlist Member plugin. These instructions may answer some of the basic questions developers using Wishlist may have about dealing with users. The following should cover the basics of using the WordPress Wishlist Member plugin.

Related Stories:

Discovering a Level’s ID in the Wishlist Member Plugin

Each level has a unique ID which is needed when using a Wishlist Member API. For some reason the level ID number is not visible from the Wishlist interface and can only be found using the following command:

$mywlmapi= new WLMAPI();


var_dump( $my_all_levels);

The dump command prints out all available levels. You then need to parse the content as follows:

array(9) { [1313304890]=> array(14) { [“name”]=> string(8) “Internal” [“url”]=> string(6) “MSgl78” [“loginredirect”]=> string(3) “—” [“afterregredirect”]=> string(3) “—” [“noexpire”]=> string(1) “1” [“upgradeTo”]=> string(1) “0” [“upgradeAfter”]=> string(1) “0”

Level ID: 1313304890

Level Name: Internal

Users may need to use this code each time they add a new level. We also discovered that the D may change when a site is migrated, so we needed to find the level number again and change the users’ level ID in the new site.

Adding a Level to a User for the Wishlist Member Plugin

In one of our solutions we needed to automatically add levels to a new user we had just created. This was done using the following code:

$mywlmapi= new WLMAPI();

$AddUserLevelsresult=$mywlmapi->AddUserLevels($UserID, array(‘1313304891’));

You can also add more than one level at the same time:

$AddUserLevelsresult=$mywlmapi->AddUserLevels($UserID, array(‘1313304891′,’1315228116′,’1313304890’));

Removing a User from a Level

Users may be removed from a specific level in the same way as they are added. You can choose to remove the user from only one level or from several at the same time. You need to specify the list of levels to remove the user from:

$mywlmapi= new WLMAPI();

$RemoveUserLevelsresult=$mywlmapi->DeleteUserLevels($UserID, array($level_id_code));

Or for several levels at a time:

$RemoveUserLevelsresult=$mywlmapi->DeleteUserLevels($UserID, array(‘1313304891′,’1315228116′,’1313304890’));

How to put a User in a Pending State in the Wishlist Member Plugin

We encountered several scenarios in which we needed to put a user in a pending state. For instance,  after registration we sent the user an activation link by email, and changed the account status to “pending” until the user activated the account via the link.

The result was that pending activation, the user could login to the WP account but could not view any documents protected by Wishlist Member. To change the account status, use the Wishlist pending function:

$mywlmapi= new WLMAPI();


To make the account active again you can use the following code:

$mywlmapi= new WLMAPI();


Find out What the Post Level is

First we need to check what the current post level is:

$mywlmapi= new WLMAPI();

$postlevels = $mywlmapi->GetPostLevels($post_id);

This will return an array including all the levels a post belongs to. Than you can check if the post includes a certain level:

if (in_array(‘LevelNametoCheck’, $levels))

Check if Wishlist Member User can View Current Post

This is a three-stage procedure. It is useful in cases where you need to check manually whether a user can view a post. This is done in the following way:

//          Finds out the user levels

$mywlmapi= new WLMAPI();

$levels = $mywlmapi-> GetUserLevels($user->ID);

//          finds out the post levels

$mywlmapi= new WLMAPI();

$postlevels = $mywlmapi->GetPostLevels($post->ID);

//          now we have two arrays and we need to check if user can view post

$levelcompareresult = array_intersect($levels, $postlevels);

if(empty($levelcompareresult)) echo ‘Error: User does not have privilege to view post<br><br>’;

Controlling Wishlist Member After-Login Page

It is impossible to control the behavior of Wishlist so that after login it directs the user to a specific page. We tried different ways of doing this, but no matter what we tried, the user is always directed after login to whatever is defined as the home page.

For instance, we tried using WordPress wp_signon, experimenting with different techniques including specifying a different after-login page in the Wishlist settings. Nothing worked. Others have also posted about this issue; so as far as we know, nobody has posted a solution.

Integrating Wishlist Member with your Online Store

In one of the solutions we needed to integrate Wishlist Member and the estore plugin. The idea was to require payment for access to a level. Behind that was the idea of selling an online course which included several pages marked with a certain WL level; these were “premium content” for which the user paid.

We therefore needed to add that level to the profiles of already-registered users who opted to buy the premium content. We achieved this by changing a bit in the estore code to send us the information needed for the after purchase process of adding the correct level to the user.