Support Forum
Hi Mr. Papa,
Your Code above to add to user group based on wishlist add level WORKS!!
Now, want to add code to remove from usergroup. The wishlist hook you mention wishlistmember_remove_user_levels, ok got that, but what is the API in simplepress to remove certain user from certain user group?
Still can't find it in Simple Press Codex.
thanks a lot for your help.
you want something like this:
add_action('wishlistmember_remove_user_levels', 'my_wl_remove_levels', 10, 2); function my_wl_remove_levels($id, $levels) { $usergroup = ''; # get usergroup id from level if ($level == 1330802121) { # Platinum $usergroup = 1; } else if ($level == 1330804171) { # Gold $usergroup = 2; } else if ($level == 1330804241) { # Silver $usergroup = 3; } else if ($level == 1330804130) { # Bronze $usergroup = 4; } # remove sp usergroup that matches membership if (!empty($usergroup)) { sp_remove_membership($usergroup, $id); } }
Visit Cruise Talk Central and Mr Papa's World
Ok I already tried your remove usergroup code above.
Then I try to remove the wishlist level from wordpress wishlist admin, but it's not work. The usergroup for the user still there in simplepress.
Is it because I try to remove wishlist level from inside Wordpress Wishlist Member Admin?
I suspect this because I find If I add level from inside wordpress wishlist member admin, the hook to add usergroup is not execute either.
Is this hook/action code can just run properly when it's called from outside the wordpress admin?
thanks a lot for your help.
where did you put them? they would need to go in your wp theme functions.php file or a separate new plugin for wp...
also, to be clear, you say remove the wishlist level... that's not what I understood you wanted... I thought you were removing a user from a wishlist level... same for adding... hope you just misspoke...
Visit Cruise Talk Central and Mr Papa's World
I put the code in functions.php in my child theme. It's already run properly for add level.
Yes sorry I misspoke (english is not my primary language), I mean removing a user from a wishlist level.
So, I would like repeat my question,
I find If I add level from inside wordpress wishlist member admin, the hook to add usergroup is not execute properly. It just run properly, if it is run from wishlist level registration URL that run by a user that sign up.
Is the hook is called only it’s called from client (outside the wordpress admin) or the hook is also called if we add/remove level from wordpress admin wishlist member?
thanks.
It should work whether in wl admin or by a user registration... we use it both ways... The 'Add to Level' or 'Move to Level' wl admin commands for user from the admin... same for remove...
Visit Cruise Talk Central and Mr Papa's World
My team already make a wordpress plugin based on your code, so it is now working properly, add/remove wishlist level will make changes to simple press usergroups.
thanks for your guidance
One more thing, how about an expired wishlist level, how you make someone that have an expired wishlist leve to automatically to remove access to simplepress forum?
wishlist don't have any hook for expired level.
How you done that in here?
thanks.
no, we just run a daily wp cron and check for expirations and if so, remove their membership...
yes, we run the code, plus the expire and a few other options from a separate plugin... but its pretty specific to our needs, ie not generic enough to release...
Visit Cruise Talk Central and Mr Papa's World
1 Guest(s)