• Skip to primary navigation
  • Skip to main content
OsomCode

OsomCode

Awesome code tutorials for WordPress and Genesis

  • Subscribe
  • My account
    • Edit profile
    • Favorites
    • Update credit card
  • Login

Add “EDD subscriber” role when reactivating an Easy Digital Downloads subscription

Learn in this tutorial how to add the role assigned by Easy Digital Downloads when a subscription is reactivated by code.

One of the most common options when creating a membership is to use the Restrict Content Pro plugin. In fact, this is what I use on this page.

But in some occasions, for example if you also want to sell digital products, Easy Digital Downloads can be a very interesting option.

To adapt EDD to create a membership you need 2 extra addons:

  • Recurrent Payments
  • Content Restriction

If you are using this combination you will have noticed that EDD grants a specific role to the subscriber which is called “EDD Subscriber”.

In a previous tutorial you learn how to remove this role when the subscription is cancelled, but in case the subscription is reactivated it is appropriate to assign it again.

This way you can use the “EDD Subscriber” role to give exclusive access or show something only to the users that have the active subscription.

Here’s how to do it:

Snippet to add the “EDD Subscriber” role when reactivating the subscription in Easy Digital Downloads

Add the following code at the end of functions.php or in your functionality plugin:

To see this and another 847 code snippets of this website, login or subscribe here.

In this case, you use the hook edd_recurring_reactivate_stripe_subscription to assign the user the role of “EDD Subscriber” when the subscription is reactivated.

This can be very handy if you want to grant some specific functionalities to the “EDD Subscriber” role and make sure that only those who have the active subscription have access to them.

Conclusion

As you can see, with a few lines of code you can add the Easy Digital Downloads specific subscriber role when the subscription is reactivated.

Any questions? I read you in the comments.

And if you want to give me any suggestion for future tutorials, leave it in the contact form. Advantages of being a subscriber. 😉

Easy Digital Downloads PHP

To leave read and make questions about this code, you can login or register.

  • About OsomCode
  • FAQ
  • Contact

Legal Notice · Privacy Policy · Cookie Policy · Terms and conditions
Copyright © 2023

Lost your password?