Support Forum

Advanced Search
Forum Scope


Match



Forum Options



Minimum search word length is 3 characters - maximum search word length is 84 characters
general-topic
Different Paid Subscription Forum using Wishlist and SimplePress
Avatar
Sukarto Sudjono
Member
Free Members
sp_UserOfflineSmall Offline
Aug 9, 2014 - 10:38 pm

Hi Mr. Papa,

Your Code above to add to user group based on wishlist add level WORKS!! smile

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.

Avatar
Mr Papa
Simi Valley, CA
SP Master
Free Members
sp_UserOfflineSmall Offline
Aug 9, 2014 - 10:55 pm

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);
    }
}
Avatar
Sukarto Sudjono
Member
Free Members
sp_UserOfflineSmall Offline
Aug 9, 2014 - 11:11 pm

Ok, after search in this forum, is it sp_remove_membership command to remove a user from usergroup? 

thx

Avatar
Sukarto Sudjono
Member
Free Members
sp_UserOfflineSmall Offline
Aug 9, 2014 - 11:13 pm

Oh just post the same time with you :)

Ok in your code, there is no "    $level = current($levels);" like add level. Is that correct?

thx

Avatar
Sukarto Sudjono
Member
Free Members
sp_UserOfflineSmall Offline
Aug 9, 2014 - 11:17 pm

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.

Avatar
Mr Papa
Simi Valley, CA
SP Master
Free Members
sp_UserOfflineSmall Offline
Aug 9, 2014 - 11:41 pm

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...

Avatar
Sukarto Sudjono
Member
Free Members
sp_UserOfflineSmall Offline
Aug 10, 2014 - 8:24 am

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.

Avatar
Mr Papa
Simi Valley, CA
SP Master
Free Members
sp_UserOfflineSmall Offline
Aug 10, 2014 - 11:39 am

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...

Avatar
Sukarto Sudjono
Member
Free Members
sp_UserOfflineSmall Offline
Aug 14, 2014 - 12:09 am

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.

Avatar
Mr Papa
Simi Valley, CA
SP Master
Free Members
sp_UserOfflineSmall Offline
Aug 14, 2014 - 1:23 am

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...

Forum Timezone: Europe/Stockholm
Most Users Ever Online: 1170
Currently Online:
Guest(s) 1
Currently Browsing this Page:
1 Guest(s)
Top Posters:
Mr Papa: 19448
Ike: 2086
Brandon: 864
kvr28: 804
jim: 649
FidoSysop: 577
Conrad_Farlow: 531
fiddlerman: 358
Stefano Prete: 325
Member Stats:
Guest Posters: 618
Members: 17356
Moderators: 0
Admins: 4
Forum Stats:
Groups: 7
Forums: 17
Topics: 10122
Posts: 79610