Sauter la navigation

Charge users for registering premium accounts dans WordPress

Membership sites can offer content available only to premium members. Toolset allows you to create front-end forms for registering new users and charge them for premium membership.

Setup

To charge user registration on your site you need three plugins:

  • WooCommerce – Creates the product that you want to sell. In our example, it’s the membership. You also use it to set up payment options and all other e-commerce settings.
  • Toolset Forms – Creates the front-end forms for registering users.
  • Toolset Forms Commerce – Connects the User Registration forms with WooCommerce and automatically creates orders when users submit the forms on the front-end.

Follow these steps

First, you need to set-up WooCommerce. This includes the store options, currency, payment gateways and other WooCommerce settings.

Then, these are the main steps you need to do to start charging for user registration:

  1. Set correct WooCommerce account-creation options
  2. Create the WooCommerce product that you’ll use to sell « memberships »
  3. Create a front-end form for registering users
  4. Set the Toolset Forms Commerce options to charge for registration

OK, let’s go through the exact instructions for each of these steps.

1. Set correct WooCommerce account-creation options

Since Toolset Forms will be in charge of creating the newly registered user accounts, it is important to set the correct account-creation options in WooCommerce settings.

What to do

What it looks like

In the WordPress administration, go to the WooCommerce → Settings page and click the Accounts & Privacy tab.

In the Guest checkout section select the first option. Deselect the first two options in the Account creation section.

2. Create the WooCommerce product that you’ll use to sell « memberships »

To charge for membership, you must first create a WooCommerce product for it.

To use WooCommerce in your site, you will need to set up additional options for it, such as payment gateways and currency. If you are new to WooCommerce, please first read about configuring WooCommerce settings.

What to do

What it looks like

In the WordPress admin, go to the Products → Add Product page.

Add a name, description, and any other information you need for your product.

In the product settings, select that the product is virtual. Then, set its price and other options.

3. Create a front-end form for registering users

You must now create the actual form that will enable user registration on the front-end. If you are new to Forms, check out our lesson about creating forms for registering users.

What to do

What it looks like

In the form’s Settings section, select Create new user and define the user role that will be assigned to the user’s registration.

Under the After user submits this form option select Go to checkout page.

In the next step, your user form will be auto-generated. Use the drag-and-drop editor to add user metadata and custom fields to it.

In the final step, you need to add an email notification to your form. This is especially important if you are using the options to auto-generate the username, password and/or nickname, because it provides the users with a way to receive this information.

Here, the most important options to select are:

  1.  Select the When submitting the form with payment details option.
  2. Make sure to select the first option, Send this notification to the billing email.

For more information, check out the lesson about sending notifications when someone submits the form.

4. Set the Toolset Forms Commerce options to charge for registration

Now that you have set up both the WooCommerce product and our user registration form, you can connect them together using the Toolset Forms Commerce plugin.

What to do

What it looks like

Edit your user form, scroll to the very bottom and find the Toolset Forms Commerce section. There, select the Charge payment with this form option.

The Toolset Forms Commerce options section will expand. In the Product to buy when submitting the form section, select the membership product you created.

Select the desired option for the Checkout process.

You can also customize the checkout and thank-you messages that will be shown by WooCommerce.

Optionally, you can change the status of the user, depending on the current payment status.

There are three user creation statuses:

  • Hide a user: User information is still stored in the database but not yet published; it is not visible on the site.
  • Delete a user: User information is deleted from the database and the site.
  • Create a user: The user is created and published on the site.

How it all works

Now that you have set up everything on your site, let’s check what users will see on the front-end and what occurs on your website regarding the order and user registration.

1. Users register on the front-end using the Toolset form

In this section, the user can set their username, password, email address, and all the information entered in the registration form.

2. After submitting the form, users reach the checkout page

The checkout page is where users can enter their shipping address and other information. This page comes from WooCommerce (you don’t need to do anything in Toolset to have this page).

After entering this information, users can proceed to pay. In our example we used PayPal, which is easily set up in the WooCommerce settings.

3. After submitting the checkout form, WooCommerce creates an « order » and sends the visitor to pay

As soon as the checkout form is submitted, WooCommerce automatically creates the order for this purchase. The default state of the order is Pendingand changes according to the status of the payment.

Ultimately, orders are either Completed after the payment transaction is completed or Cancelled. Payments are canceled if the user does not complete the payment.

The visitors go to the payment gateway that you’ve selected in WooCommerce.

4. After payment is completes, WooCommerce updates the order status and users return to the site’s Order Received page

After payment is completed, the order is marked as Complete and the user is registered on the site.

Please note that with some payment options, such as PayPal, the order will not be automatically marked as Complete after the user pays for the product. You will receive the automatic payment email notification and invoice from WooCommerce; however, you will need to manually mark the order as Complete.

There are third-party plugins that solve this issue and automatically mark the orders Complete.

The visitor (who’s now a customer) reaches the site’s Order Received page. This page comes from WooCommerce and summarizes the order details, a cost of the bought product, customer details, etc.

Updated
juillet 13, 2021