Support Forum
There is an easy way to do this if the membership plugin utilises the WP standards correctly. And that is with Wp role mapping (forum admin > user groups > map users to user groups. This can automatically move users from one forums user group to another (i.e., with differing permissions) with their status change but it does relate to WP roles.
This FAQ discusses how to set SP up with a membership plugin - in this case WishList Member - but th e process and theory is the same...
YELLOW
SWORDFISH
|
Thanks, but I have already done that. Simple membership adds a flag to the account of 'expired' which still allows the user to log in so they can renew their subscription but leaves their user role alone.
I can get the user's expired status with a pip function and would like to be able to check for that as a second authorization.
Well - the natural methodology that Simple:Press adopts is to move a user from one user group to another - i.e. if you took our default user groups as installed - it could move someone from the members group into the guests group (for example) which can be automatically achieved by role mapping. And that has no impact ion whether a user can log in or not as login is not a function of Simple:Press bit a function of your website.
So it sounds like your membership plugin is unable to do this. Which would mean, perhaps, a coded solution which is probably easy to achieve.
Perhaps a little more detail then would help us to advise on the options. You said at top that you would like to 'deny posting ability'. Does that mean you want to make the forums read-only? Or you want to remove them completely? If you can describe what you want to happen it will make it easier..
YELLOW
SWORDFISH
|
hi
what I want to do is basically move the member to the guest group for as long as their subscription flag is set to expired. If they then renew they will be moved into the members group. The problem with the group mapping is that it does not see the subscription flag as an option so cannot pick up on it. It will definitely need to be a coded solution, I am hoping that this can be achieved through added functions to the theme?
I don't know, of course, how familiar you are with WordPress coding so please excuse me if I aim this too high or too low!
WordPress allows plugins to interact with the core by the use of 'hooks' (filters and actions) which you can think of as a sort of messaging system. Any decent plugin, especially one that may have to inform other plugins - should implement their own series of hooks.
In the case of what you want to do you are needing an 'action' hook that your membership plugin implements after they change this flag. If you know this - and know the data it sends - then we can work out the best SP functions to call to change a users user group.
YELLOW
SWORDFISH
|
I have trawled through the code for the simple membership plugin, they have no api and only a few hooks for the login validation process. The expired status is set by a direct database edit handled by a cron job that runs every day. They do have a way to check that flag though.
if(SwpmMemberUtils::is_member_logged_in()) { $auth = SwpmAuth::get_instance(); $expired = $auth->get('account_state'); //handle member switch here }
Maybe hook into the wp login process and move the user to guest after running this check?
Well - of course I can not really condone hacking into any code when there is a perfectly good API to utilise but still...
The functions you will need to look at are in the /simple-press/sp-api/sp-api-users.php file. They are:
sp_remove_membership($usergroup_id, $user_id); sp_add_membership($usergroup_id, $user_id);
This is where using the API helps though. If done through a hook we would be making sure all the necessary support code was loaded but within those 2 functions a few more files would also need to be included.
if I was you - and was 'hacking' here then personally I would just take a look at the SQL being applied and just use that. Two simple queries is all that is needed for the remove and add operations.
But you will also need to perform a clear of the 'memberships' and 'auths' columns for the user in the 'sfmembers' table because the data in there is cached so would need to be rebuilt.
YELLOW
SWORDFISH
|
Hi swordfish
Many Thanks but it seems a lot to go through with a good possibility that I will probably do something wrong and break everything.
Instead I am looking at adding a new hook into the simple membership cron-job that will allow me to run a function on any member who gets changed to expired. I can then add a function to my theme functions to change the user role to a custom role I have added and mapped to the guest group of the forum.
Seems like an easier way forward. I am just waiting to hear back from the plugin developer ( to make sure my alteration won't break anything).
I'll keep you informed, it may be useful to other users who want to use simple membership and simple::press together.
1 Guest(s)