Duplicate Snippet
Embed Snippet on Your Site
MemberPress: Remove a User Role After Subscription to a Specific Membership Expires
The code snippet will remove the specified role from a user after the user’s subscription to a specific membership expires.
Replace the dummy membership ID of "123" with the ID of the needed membership on this line:
if ($txn->product_id == '123') {
Next, replace the dummy "custom-role" user role on this line:
$user->remove_role('custom-role');
Replace the dummy user role with the name of the actual user role related to the membership specified in the code.
Code Preview
php
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
Comments