WishList Member is a powerful WordPress plugin that allow to protect WordPress contents such as post or even files by adding levels to WordPress users. It have friendly user interface and easy to us. But you can go farther to do whatever you want using Wishlist member API. Here I want to show you how easy you can add new levels directly from code.
Example code:
$my_user_id=2;
$mywlmapi= new WLMAPI();
echo "<h3>1) we want to see user levels </h3>";
echo "<pre>";
$my_user_levels=$mywlmapi->GetUserLevels($my_user_id );
var_dump( $my_user_levels);
echo "</pre>";
echo "<h3>2) we want see all levels details </h3>";
echo "<pre>";
$my_all_levels=$mywlmapi->GetLevels();
var_dump( $my_all_levels);
echo "</pre>";
echo "<h3>3) we want to add a levels </h3>";
echo "<br><pre>";
$AddUserLevelsresult=$mywlmapi->AddUserLevels($my_user_id, array('1288000851'));
var_dump( $AddUserLevelsresult);
echo "</pre>";
echo "<h3>4) again we want to see user levels </h3>";
echo "<pre>";
$my_user_levels=$mywlmapi->GetUserLevels($my_user_id );
var_dump( $my_user_levels);
echo "</pre>";
And here is example output
1) we want to see user levels
array(1) {
[1288000826]=>
string(6) "silver" <-------- user with id=2 only have one level with level id= 1288000826 which is silver level
}
2) we want see all levels details
array(2) {
[1288000826]=>
array(12) {
["name"]=>
string(6) "silver"
["url"]=>
string(6) "Sdep89"
["loginredirect"]=>
string(3) "---"
["afterregredirect"]=>
string(3) "---"
["noexpire"]=>
string(1) "1"
["upgradeTo"]=>
string(0) ""
["upgradeAfter"]=>
string(0) ""
["upgradeMethod"]=>
string(0) ""
["count"]=>
string(1) "1"
["role"]=>
string(10) "subscriber"
["levelOrder"]=>
string(0) ""
["ID"]=>
int(1288000826)
}
[1288000851]=> <----------- Golden level id that we want add it to user levels
array(10) {
["wpm_newid"]=>
string(10) "1288000851"
["name"]=>
string(6) "golden"
["url"]=>
string(6) "NOWYj2"
["loginredirect"]=>
string(3) "---"
["afterregredirect"]=>
string(3) "---"
["noexpire"]=>
string(1) "1"
["role"]=>
string(10) "subscriber"
["levelOrder"]=>
string(0) ""
["count"]=>
string(1) "1"
["ID"]=>
int(1288000851)
}
}
3) we want to add a levels
bool(true) <--- level is added with no problem
4) again we want to see user levels
array(2) {
[1288000826]=>
string(6) "silver"
[1288000851]=>
string(6) "golden" <-------- user now have two levels, silver and golden
}
Example Screenshots:
http://screencast.com/t/3YMSUOM4lxN
http://screencast.com/t/yWVDuhsxkF
http://screencast.com/t/w2jjp6Hcfg
http://screencast.com/t/2cXIgm15R
http://screencast.com/t/b3g2DzOGNEvH
Wonder what is Wishlist member wordpress plugin and what it can do? check here
Do you need Professional coder? Hire me
Looking for different WordPress plugin? Try Wishlist member
Andy is one of core WordPress WishList Member Developer. He is in love with WordPress and fun of turning new ideas to WordPress plugin or theme.


