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
Note: This guide requires:
- WordPress Invitation Code plugin - This document uses version 1.7.5.
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:
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
- Selecting user roles allowed to create codes on the front-end
- Displaying front-end form - shortcode
- Enabling floating widget
- Editing front-end labels
- End result
Installing the Plugin
The process is the same for all CM plugins and add-ons.
- 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.
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.
Save the changes after choosing user roles.
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.
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:
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.
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:
Scroll down, find the section Widgets and turn on the option Enable Create Code Widget:
Then save 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.
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:
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.
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.
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.
The labels under the section Create Code Frontend Form are related both to the front-end form and a floating widget:
And a few more labels specifically for a widget can be found under the section Widget for Create Code Form.
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:
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 |