<img height="1" width="1" style="display:none" src="https://www.facebook.com/tr?id=442498563201411&amp;ev=PageView&amp;noscript=1">

Use Cases: User Management With LaterPay's WordPress Plugin

img-integrations-other
Topics: Use Cases
Experience Level: Advanced
October 31, 2019 · 10 min read

 

 

 

 

 

 

In addition to operating as a standalone system LaterPay can also be used as a complement to your own user management system.

 

We have found User Role Editor https://wordpress.org/plugins/user-role-editor/ to work quite well with the LaterPay WordPress plugin; so we will be referencing that throughout our guide. For user sign up form functionality, we will be using Profile Builder. You can, of course, explore other plugins as well, however we cannot guarantee that they will work optimally with our plugin.

 

Both plugins extend the basic WordPress user management functionality, meaning that a lot of the native WordPress functions can be reused.

 

The scenario

In this guide, we will illustrate how User Role Editor and Profile Builder can be used in combination with the LaterPay plugin in order to fulfill, in our experience, one of the most often encountered scenarios, namely when a publisher wants to offer users a single topic of their choice free of charge, but would like to use LaterPay to monetize other topics.

So what do we need to have at the end? Users will need to be able to create a user account on your website to freely access paid content that is part of a certain category. For users wanting to access additional content beyond the single category, you can in addition offer LaterPay purchasing options.

Let us say, for example, that you would like all your registered users to have access to a single predefined category (“Cooking” in our example) and they will have to purchase either single articles, or subscriptions to view content from other categories. This implies the following components need to be part of your website:

 

  1. A user management system, where registered users will have a specific role
  2. Users need to be able to sign up
  3. Users need to be able to login after they have signed up
  4. Activate a LaterPay subscription for all articles on the website
  5. The ability for logged-in users to view content from the designated category (“Cooking”) freely
  6. Logged in users will still be presented with a paywall for categories other than the designated one

Implementation

In this chapter, we will show you how to implement the six essential components that need to be part of your website to meet the requirements outlined in the sample scenario.

 

1. A user management system, where registered users will have a specific role

 

Note: Before you begin, you should determine how you want to manage users and roles on your website. We recommend that you go through the up-to-date plugin documentation, where you should find all the answers and inspiration you need: https://www.role-editor.com/documentation/

 

 

In this guide, we will be adding a single user role and associating a single user to it, just to show you how to enable your webpage to have paid content with the LaterPay plugin.

So, we first have to create a custom role. Custom roles are required so that you can control LaterPay’s plugin behavior based on which role the user is logged in with. We’ll go into more depth later.

Navigate to your WordPress admin site -> Users -> User Role Editor. You will be prompted with a panel where you can select a role and change its capabilities.

Let’s add a new role, give it an ID “free”, and the display name “Website Subscriber”. In addition, let’s copy its permissions from “Subscriber”, which is the most suitable WordPress role.

 

 

Note: The way you configure permissions assigned with a new role or user depends strongly on your context. Please consult the User Role Editor documentation for more information.

 

 

the way you configure permissions assigned with a new role or user depends strongly on your context. Please consult the User Role Editor documentation for more information.

 

Image 1

After we have added this role, and assigned the right permissions to it (use the permissions menu in the plugin), we need to have a new user for testing purposes.

 

2. Users need to be able to sign up

 

How do you enable users to sign up? There are a number of plugins out there, but the one we recommend is Profile Builder. You can use this plugin to create registration forms that are assigned to default roles, and then change the roles later as needed.

In order to install this plugin, navigate to Plugins -> Add New and search for “Profile Builder.” After installing and activating the plugin, you can use the sidebar to navigate to Profile Builder -> Basic Information, where you will be asked whether you want to create default pages (namely Login and Register pages). You can click on the button to create the pages.

You can now navigate to Pages -> All Pages where a “Register” page will be created that will look something like this:

 

Image 2

 

This is a registration page which you can direct new users to in order to register on your website. Please refer to this plugin documentation for directions on how to customize, add and remove fields in the registration form.

Next you need to setup a default role for newly subscribed users. In order to do this, go to Settings->General, and set the New User Default Role to the newly created “Website Subscriber.”

Image 3

Bear in mind  that the usual recommendation here is to navigate to Profile Builder -> Settings and set the Minimum Password Strength to “Strong.” This way you can prevent fraudulent users from creating accounts on your website with simple passwords. The other settings on this page can be used according to your preferences.

Let’s test our new registration page. Navigate to the user page (or go to Pages->All Pages ->Register->Preview) and register a new user, filling in all the data. At the end of this process, you should be able to see the new user show up on the list of users (Users->All Users) with the role “Website Subscriber” associated to it.

 

3) Users need to be able to login after they have signed up

A new user is able to register now, however we still need to enable this user to log in. You can navigate to the login page (or go to Pages->All Pages ->Register->Preview) and log in using the same credentials defined when you signed up.

A note to advanced users - the login functionality can be added to all your pages as well. For instance, if you would like to add the login button in the sidebar, you can navigate to Appearance->Editor->Sidebar (Sidebar.php) and add the following code snippet to the page, wherever you deem it appropriate:

if (!is_user_logged_in()) {
wp_login_form();
}

 

This will add the standard WordPress login functionality to the sidebars of all the pages on your website.

 

4) Activate a LaterPay subscription for all articles on the website

You might have performed this step already, but let’s go over it again to make sure we can test our new configuration.

This step is rather straightforward: first you need to create two posts - one assigned to the category which is designated to be free-to-view for subscribed users (“Cooking” in our example), and another that can be in any other category.

In the screenshot below, you can see an example for an article in the “Cooking” category, to which we have also added an individual price of 30 cents.

 

Image 4

Once that’s done, add a subscription to all articles on the webpage. This process is rather simple - all you need to do is to navigate to LaterPay->Pricing and go to the Subscriptions category. There you can add a new subscription, choose the duration and price, and set it to cover the categories you choose. For our example, we have created a 1 month subscription costing €1,49 and covering all categories.

 

Image 5

 

Navigating to our “Cooking Article” after these changes are done will now look like this:

 

Image 6

5) Logged in users need to be able to view content from the designated category (“Cooking” in our example) freely

Now that a user can sign up, log in, and will be assigned to the custom role we have defined (“Website Subscriber”), let’s focus on how they will interact with the LaterPay plugin.

First navigate to Settings->LaterPay. We will focus on the first part: Access control. If your custom role is properly defined, you will see it listed here as “Website Subscriber” and there will be checkboxes defined next to it which you can use to define the access rights (see screenshot). By default, the custom roles are set to have unlimited access to “none.”

 

Image 7

Let’s change this. By unchecking the “none” category, all available post categories will be displayed. Now you can select the category for which this user will have free access. Let’s select “Cooking.”

 

Image 8

Finally, navigate to the login page (perhaps using a different browser, since you are logged in with your admin account) and log in using the same credentials defined when you signed up. If you check your “Cooking Article” again, while logged in with the test user, the paywall will not be there.

 

6) Logged in users will still be presented with a paywall for categories other than the designated one (“Cooking” in our example)

This part is easy. While you are still logged in as your newly-created user, navigate to another post in any other category than “Cooking” - in our example, this is “Travel Test”. You will see that the paywall is still there. Success!

 

Image 9