Learn in this tutorial how to allow a user role to not have the simultaneous access limit applied to it when using the Loggedin plugin, through code.
If you have a membership site, it is possible to limit the number of simultaneous logins of a subscriber. One option to do this is by using the Loggedin plugin.
But if you have several membership levels, you may want to offer (for a higher price, for example) the option of not applying this restriction.
Here’s how to do it:
Snippet to not limit the number of simultaneous accesses for a user role
Add the following code at the end of functions.php or in your functionality plugin:
To see this and another 1091 code snippets of this website, login or subscribe here.
In this case, you use the loggedin_bypass
filter to indicate that the subscriber_plus
user role is not subject to the simultaneous access limitation.
The role to which the exception is applied in this case is subscriber_plus
but the idea is that you change it for the user role you want. You will need to create it first following the tutorial where I explain how to create a custom user role.
If you are using Easy Digital Downloads to create the membership, you may also be interested in the tutorial where I explain how to assign a custom user role depending on the product being purchased.
Conclusion
As you can see, with a few lines of code you can add an exception to the limitation of simultaneous accesses of subscribers, depending on the user role they have.
If you have any question, please leave it in the comments. And if you want to give me a suggestion for future snippets, please send it through the contact form.
Benefits of being a subscriber. 🙂