WordPress Invitation Code - Use Case - How To Let Specific User Roles Create Invitation Codes From On Front-end


Use Case - How To Let Specific User Roles Create Invitation Codes From On Front-end

Back to User Guide

Note: This guide requires:

Introduction

With the WordPress Invitation Code plugin it is possible to let selected user roles create invitation codes on the front-end. It can be done either using a front-end form or a floating widget. The front-end form and a floating widget are simplified in comparison with the full back-end form.

Use Case Front-End

Front-end form for creating codes:

Front-end form for creating codes - Invitation Code Registration for WordPress
Front-end form for creating codes

Floating widget for creating codes:

Floating widget for creating codes - WordPress Content Restriction
Floating widget for creating codes

Use Case Assumptions

In this example use case guide we will consider how to enable the front-end form and a floating widget for creating codes, and how to select user roles which are allowed to use them.

We consider that you have already bought the WordPress Invitation Code plugin, but not installed it yet.

It follows:

Installing the Plugin

The process is the same for all CM plugins and add-ons.

CreativeMinds Customer Account Dashboard - Downloads tab
CreativeMinds Customer Account Dashboard
  • Download the plugin from your customer dashboard.
  • Log in to WordPress and navigate to the WordPress Admin â†’ Plugins settings.
  • Click on Add New.
  • Activate it and add the license.

Learn more: Getting Started - Plugin Overview


Selecting User Roles Allowed to Create Codes On the Front-end

First thing you need to do is to select which user roles are allowed to create invitation codes on the front-end. To configure it, navigate to Admin Dashboard → Invitation Code Content Access → Settings → General tab.

Navigation to the plugin settings - Private Content WordPress Plugin
Navigation to the plugin settings

Find the option Allow creating codes on the front-end for specific user roles. Here you can choose which user roles will be able to use either a front-end form or a floating widget for creating codes.

Selecting user roles for creating codes on the front-end - Restrict Content Plugin
Selecting user roles for creating codes on the front-end

Save the changes after choosing user roles.

Saving the changes - WordPress Invitation Code
Saving the changes

TIP

Ensure that access to content is not restricted for the user roles that are allowed to create codes. You can select user roles that you lock the content for using the option Access denied for specific user roles.

Selecting user roles for locking the access for them - WordPress Register with Invitation Code
Selecting user roles for locking the access for them

Displaying Front-end Form - Shortcode

To display a front-end form for creating shortcodes, you need to use the shortcode

[cmicca_create_code_form] .

The shortcode includes several parameters:

  • allow_roles - This parameter allows to override the global setting and redefine the user roles that are allowed to use the form for creating codes.
  • hide_codes - This parameter allows to hide the list of generated codes. The default value is "0".

Examples of usage:

[cmicca_create_code_form allow_roles="admin,editor,author"]

[cmicca_create_code_form allow_roles="admin,editor,author" hide_codes="1"]

So let's create a page and add there a basic shortcode:

Adding shortcode - WordPress Invitation Code
Adding shortcode

Front-end Example:

The form allows the user to do the following:

  • Code - Enter a custom code or generate a random one by clicking the button Generate new.
  • Valid from - Define the date and time from which the code can be activated.
  • Expiration Time - Define how long the content will be unlocked since the moment the code was activated. The time can be set in Minutes, Hours or Days.
  • Enter Posts/Pages URLs - Define here one or multiple URLs that you want to create a code for. Each URL should be placed on a separate line.
  • Create Code - Click it to create the code.

Below the form the user can see the codes generated only by him. The expired codes are marked with the relevant label. The part with the list of codes can be hidden with a shortcode parameter hide_codes.

Front-end form for creating codes - Portal WordPress Plugin Private Content Per User
Front-end form for creating codes

Enabling Floating Widget

Another way to let users generate codes on the front-end is using a floating widget.

This widget can be displayed only on selected pages, and the codes are generated for the page where the widget is displayed.

To enable the widget feature, get back to the General plugin settings:

Navigation to the plugin settings - Members Plugin Restrict Content
Navigation to the plugin settings

Scroll down, find the section Widgets and turn on the option Enable Create Code Widget:

Widgets settings - Invitation Code Registration for WordPress
Widgets settings

Then save the changes.

Saving the changes - Invitation Code Registration for WordPress
Saving the changes

Once it's done, a metabox will appear on all posts and pages in the editing mode. Just start editing needed post or page and find the metabox Widget for Creating Invitation Codes, check the option Enabled and save the changes.

Enabling widget for creating codes - WordPress Content Restriction
Enabling widget for creating codes

Once it's done, the floating widget will be displayed on the front-end for this post only for user roles that are defined in the plugin settings.

The widget is placed at the bottom right of the page. The widget is initially minimized and can be expanded or collapsed by the user at any time:

Using the widget - Private Content WordPress Plugin
Using the widget

The form in the widget has the following options:

  • Code - Enter a custom code or generate a random one by clicking the button Generate new.
  • Valid from - Define the date and time from which the code can be activated.
  • Expiration Time - Define how long the content will be unlocked since the moment the code was activated. The time can be set in Minutes, Hours or Days.
  • Create Code - Click it to create the code.

The code is created only for the page where this widget is used.

Form for generating codes in the widget - Restrict Content Plugin
Form for generating codes in the widget

The widget consists of 2 pages, and for switching between them the widget has 2 buttons at the bottom - Generate code and Created codes.

The page with created codes shows the list of codes created only for this page and only by the user who uses this widget. A date of creation is shown for each code, and if the code is expired - it has a relevant label.

List of generated codes - WordPress Register with Invitation Code
List of generated codes

Editing Front-end Labels

The WordPress Invitation Code plugin allows you to edit or translate to another language every label related to the front-end form or a floating widget. To do this, navigate to Admin Dashboard → Invitation Code Content Access → Settings → Labels tab.

Navigation to the labels settings - Portal WordPress Plugin Private Content Per User
Navigation to the labels settings

The labels under the section Create Code Frontend Form are related both to the front-end form and a floating widget:

Create Code Frontend Form labels - Members Plugin Restrict Content
Create Code Frontend Form labels

And a few more labels specifically for a widget can be found under the section Widget for Create Code Form.

Widget for Create Code Form labels - WordPress Invitation Code
Widget for Create Code Form labels

End Result

Following instructions found in the plugin and guides, you should be able to enable the front-end form and a floating widget for creating codes, and how to select user roles which are allowed to use them.

Use Case Front-End

Front-end form for creating codes:

Front-end form for creating codes - Invitation Code Registration for WordPress
Front-end form for creating codes

Floating widget for creating codes:

Floating widget for creating codes - WordPress Content Restriction
Floating widget for creating codes

More information about the WordPress Invitation Code Plugin

Other WordPress products can be found at CreativeMinds WordPress Store

Let us know how we can Improve this Product Documentation Page

To open a Support Ticket visit our support center
Did this answer your question? Thanks for the feedback There was a problem submitting your feedback. Please try again later.