How it works...

The plugin uses shortcodes to provide custom login and registration forms as well as frontend profiles. We started the recipe by configuring the built-in settings of the plugin. Once it's installed, the plugin creates a page for login and assigns by default the Login Page settings. We can change the default page to a custom page by modifying these settings. However, if we assign a different page, we also need to add the ProfilePress login shortcode to that page.

Then, we configured the logout redirection and login redirections by selecting the necessary pages for the Logout and Login settings. These settings are not assigned to the shortcode as parameters. Instead, the plugin will internally get these details from the database and assign them to the necessary hooks.

Next, we move on to the stage of using the shortcode. By default, the plugin uses the first of the three designs with the shortcode [profilepress-login id="1"]. Once we change the design, the ID will change to 2 or 3. In this case, we selected the third design. Once the shortcode is added and the page is viewed, we see the custom design for the shortcode generated from the plugin.

Then, the user can add the username and password and click the Login button to log in to the site. The plugin uses standard WordPress hooks and functions to check the user credentials and log the user in to the site. We configured two settings for login and logout URLs. This plugin uses built-in WordPress hooks (as shown in the following code) to enable these features:

add_filter('login_url', array($this, 'set_login_url_func'), 99, 3);
add_filter('logout_url', array($this, 'logout_url_func'), 99, 2);

These are two built-in features used to modify the default redirection URLs for login and logout. The plugin uses the login_url and logout_url filters with a callback function to get the settings we configured and redirect the users to the respective URLs.

We can use this plugin or similar plugins to enable a frontend login on the site. Most plugins use the shortcode technique. We have the ability to match the design of the site and give a custom frontend login form without letting the users log in through the backend login form.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset