Warning: A non-numeric value encountered in /home/simpliko/wpadverts.com/public_html/wp-content/themes/Divi/functions.php on line 5806

Memberships (Paid Add-on)

Posted in: Modules and Extensions

The Memberships extension allows displaying different pricings to users based on their roles or capabilities. You can also use the plugin to limit some pricings usage (for example by allowing max 3 postings in 10 days).

Installation and Setup

In order to use the WPAdverts Memberships plugin you need to first purchase, download the zip file install it from wp-admin / Plugins / Add New / Upload panel and activate.

Once you do that you will also need to create some pricings either from wp-admin / Classifieds / Options / Payments / Pricing panel. You will need to enable Payments Module to do that.

At this point, it is good to know how what membership levels your website will have and what pricing options each membership level will allow so you can create all the needed pricings.

For this tutorial, i am creating 3 pricing options

  • Free ($0; visible for 3 days)
  • Premium ($0; visible for 15 days)
  • Premium Featured ($5; visible for 15 days and featured)

I want unregistered users to be able to only post Free ads visible for 3 days and any logged-in user to be able to post either Premium or Premium Featured Ads.

Users will be able to post an unlimited number of Premium Featured Ads and only 10 Premium Ads within 30 days.

Configuration

Go to wp-admin / Classifieds / Memberships / Pricings panel you will see there a list of pricings (listing types) created earlier.

You can click on one of the listing types, it will show you a form which allows restricting the pricing usage. It will look like on the image below

WPAdverts Memberships Pricings List

There are a few key things to keep in mind when configuring the pricings:

  1. By default, each pricing is visible and can be used by anyone, the restrictions are being applied once you make some changes to the listing type options.
  2. The limit and interval options are applicable only to logged-in users as there is no way to track the usage for not logged in users.

Speaking of options each pricing has the following:

Allow unlimited usage – checking this checkbox will allow unlimited use of this pricing.

Max Uses – if “Allow unlimited usage” is unchecked then in this field you can enter how many times this pricing can be used by a user (in “Post Status” field we will define how the usage will be counted).

Interval insensitive – behind this enigmatic option name is hidden an option which allows deciding if “Max Uses” should renew or not.

In other words if “Max Uses” is set to 10 and the “Interval insensitive” checkbox is unchecked then the “Max Uses” limit will be global and once a user will use it 10 times he will not be able to use it anymore.

If you uncheck the “Interval insensitive” checkbox then below you will be able to enter the interval (integer number) which is a number of days. If you again enter here 10 then the usage will be count for the last 10 days (instead of globally).

For the “Premium Ad” we wanted to allow users to post max 10 Ads (with this type) within 30 days and on the screenshot above the “Premium Ad” pricing is configured like that.

Interval – a number of days used to check the pricing usage. In our example, it is set to 30 because we want to check if this pricing was used 10 times within the last 30 days.

Capabilities – here you can select one or more capability required to see the pricing in [adverts_add]. In the text input, you can enter the capability name to quickly filter the available capabilities list.

Note that if you will not select any capability then the pricing will be visible to anyone.

You can, for example, check “read” capability to make the pricing visible only to registered users. We will be doing this for Premium and Premium Featured Ads.

Post Statuses – this is a list of post statuses to use when counting usage.

For example, if you want your users to have max. 10 active ads then you can set the “Max Uses” to 10 and in the Post Statuses check “Published”.

On the other hand, if you want to allow max 10 postings (regardless of their status) you can set “Max Uses” to 10 and in the Post Statuses check all available statuses. Then if the user will have 5 active ads and 5 expired ads then Memberships plugin will mark the pricing as “limit reached”.

Note that the post statuses list is different when configuring restrictions for new-posting and renewals pricings.

In the case of new-postings, the statuses are the statuses of posted Adverts, in case of renewals, these are statuses of renewal payments associated with the Advert.

Configuring Pricings for Tutorial

In order to configure the created pricings as explained at the beginning of this article we will need to do that following:

Free – do not change anything we want it to be visible to anyone

Premium – (allow using it 10 times within last 30 days for logged in users) in Max Uses enter 10, in Interval 30, in capabilities select “read”.

Premium Featured – (unlimited usage for logged in users), check “Allow unlimited usage” and in capabilities select “read”.

A couple of more examples so you can better understand what is possible with the Memberships and how to use them:

Max 15 active Ads – in Max Uses select 15, check “Interval insensitive”, in capabilities select “read” and in Post Statuses select “Publish”.

5 Trial Postings – in Max Uses select 5, check “Interval insensitive”, in capabilities select “read” and in Post Statuses select all options.

Memberships

If you are using some third-party membership plugin for managing the Memberships and your plugin can add capabilities to users when the membership activates and remove the capabilities when membership is deactivated then you can use your plugin to managed memberships.

If you do not have a Memberships plugin yet or it cannot integrate with WPAdverts Memberships then you can use the builtin memberships engine.

Creating a Membership Plan

You can create a new Membership Plan from wp-admin / Classifieds / Options / Memberships / Add New Plan … panel. The add (and edit) membership plan will look like on the image below

Add Or Edit WPAdverts Memberships Plan

There are the following fields in the form:

Title – the plan title, usually it will be something like “Silver Plan” or “Pro Plan”.

Price – how much purchasing this plan will cost. If you check the “This plan has a different renewal price” then below a field “Renewal Price” will show where you can enter a renewal price.

One common use for the “Renewal Price” is to make it higher than the original price. Then the users can get a membership at a discounted price to try it out and then if they will like it, the membership will renew with the higher price.

Duration – how long the membership will be active or in other words how often (in days) the user will be charged with the renewal price.

Is Active – if unchecked the users will not be able to purchase this membership plan.

Grants Capabilities – The capability or capabilities the user should receive when the membership is activated.

You can use any capability you want but it is best to use some custom capability for example prefixed with “plan_” like “plan_bronze” so you won’t accidentally grant an admin only capability to a Subscriber.

Pro Tip: If you would like to give users with the valid membership access to some custom pages or functionality then you can check if the user has the membership enabled using the WP current_user_can() function. In this case

<?php
if( current_user_can( "plan_bronze" ) ) {
  echo "Custom Text For Members Only ...";
}
?>

Description – In this field, you can describe what is included in the membership package. The description will be shown in the frontend when user will see membership plans available for purchase.

Which Pricings Are Included In The Membership?

In the Membership Plan configuration, we never selected what pricings will be included in the Membership. This is because in the access to Pricings is granted based on the user capabilities only.

If when configuring the Membership Plan in the Grant Capabilities field you have added a “plan_bronze” capability then you can now go to wp-admin / Classifieds / Options / Memberships / Pricings panel and check this capability in the Capabilities field in the pricings which should be available to the user with active membership.

Managing Memberships

Most often administrators will want users to purchase the memberships in the frontend but it is also possible to allow to assign the memberships to users manually from wp-admin panel.

The Memberships list you will find in wp-admin / Classifieds / Options / Memberships / Memberships panel.

List of purchased memberships.

From here you can click “Add New Membership …” button to assign a new membership to a user manually, filter the list by Plan and Membership Status.

You can of course also edit a membership by clicking on its ID or “Edit” button next to it. The Add and Edit pages look pretty similar

Edit existing membership.

The membership form has a couple of fields:

Assigned User – The user from wp-admin / Users panel to whom the membership is assigned.

Assigned Plan – The membership plan assigned to the user.

Started At – The date and time when the membership was purchased (and paid).

Expires At – The date when membership will expire, which basically comes down to removing assigned membership capabilities from the user.

Payment Method – The payment method the user has used when making the last payment for the membership. This is also a default payment method which will be selected when a user will want to make a payment for the next membership period.

Status – The membership status. One of active, past-due and canceled.

When editing a Membership you will also see a Payments History widget in the right sidebar which lists all of the payments related to this membership. That is the initial payment made to purchase the membership, renewal and pending payments.

If you click on the payment ID you will be redirected to the wp-admin / Classifieds / Options / Payments page where you will be able to see more details about this payment.

Shortcodes

The WPAdverts Memberships plugin has two shortcodes which allow purchasing a membership and managing it in the frontend. Kind of a self-service for the users to purchase a membership, pay for it, renew and disabled when the user no longer wants to use it.

Purchasing a Membership [wpadverts_memberships_purchase]

By now you should already be able to set up the memberships for your users manually. But, what if you want the users to purchase the memberships themselves?

To do that you need to go to the wp-admin / Pages / Add New panel, set a title for example “Purchase Membership” and in the page, content put [wpadverts_memberships_purchase] shortcode.

When you will view the page in the frontend you should see something similar to the image below

Membership pricing table in the frontend.

This is basically a layout for plans defined in “Creating Membership Plan” section in this article. After clicking one of the Purchase buttons you will be redirected to the default Payments Module checkout where you can complete your purchase.

Managing Memberships [wpadverts_memberships_manage]

Instead of using [wpadverts_memberships_purchase] shortcode you can use the [wpadverts_memberships_manage] shortcode instead. It allows viewing the current and past memberships and has a button for purchasing a new membership.

See how it works on the screencast below

Managing memberships in the frontend.

(click on the image above to play it)

The [wpadverts_memberships_manage] shortcode allows purchasing membership filtering memberships by status, viewing payments related to the membership and canceling the subscription.

Options Page

Usually, users will not remember when their membership expires, and if they are paying for the membership using Bank Transfer or PayPal you need to remind them to do that.

Fortunately, WPAdverts Memberships plugin has functionality which will do that for you automatically. When to generate a new invoice and when to notify the user about it you can configure from wp-admin / Classifieds / Options / Memberships / Options panel.

Membership Options

There is a couple of options here:

Generate Invoice – it allows selecting how long before the membership expiration the renewal invoice should be generated.

Send First Notification – allows selecting when the first notification email with payment instructions should be sent.

Of course, the selected number of days needs to be smaller than in the Generate Invoice field as the invoice needs to be generated first and only then the notification can be sent.

Send Second Notification – allows selecting when the second notification email with payments instructions should be sent.

This notification is sent only if the user hasn’t paid the invoice yet.

First Failed Attempt, Second Failed Attempt – these two fields have pretty much the same functionality. If the user hasn’t paid the invoice X days after membership expiration then notify him.

Finally – what to do once all the notifications are sent. Usually, you will just want to cancel the membership and NOT keep it in past-due status as the past-due membership is technically still active.

Note that for each setting except Generate Invoice you have a “Do Nothing” option which will disable sending the notification.

Notification Logs

The email notifications are sent to users in the background by WP-CRON. You should not need to check on them, but if it will turn the notifications are not sent you can check the notifications log.

To see the log go to wp-admin / Classifieds / Options / Memberships panel, scroll to the bottom of the page and click the “Memberships Logs” link it should be next to the “Thank you for creating with WordPress.” text.

The log will look similar to this

Memberships Logs

It should be helpful with troubleshooting messaging issues.

The first thing to check is the date and time when the memberships wp-cron event should be executed. Ideally, it should be within the next 30 minutes. If the event is scheduled for the date in the past or is disabled then it might be a problem with the WP-CRON itself.

You can try fixing it by setting up a real UNIX Cron which will be more reliable then the WordPress based on. How to do that you can read here.

Integrations

Out-of-box the Memberships plugin is integrated with a couple of WPAdverts Extensions.

Authors Extension

The integration with Authors Extension will insert a “Memberships” link inside the [adverts_author_manage] menu.

You will not need to create a separate [wpadverts_memberships_purchase] page as it will be already there in the Author panel.

WooCommerce

You can use the WPAdverts WooCommerce integration with WooCommerce Memberships and WooCommerce Subscriptions to charge users a recurring membership if you do not want to use the builtin Payments Module based memberships.

In this case, you will need to set up your membership plans differently using WooCommerce Products and Memberships. We have a separate documentation page for the WooCommerce based Memberships setup.

Emails Module

@todo