Simple Jwt Login Shortcode

Below, you’ll find a detailed guide on how to add the Simple Jwt Login Shortcode to your WordPress website, including its parameters, examples, and PHP function code. Additionally, we’ll assist you with common issues that might cause the Simple Jwt Login Plugin shortcode not to show or not to work correctly.

Before starting, here is an overview of the Simple Jwt Login Plugin and the shortcodes it provides:

Plugin Icon
Simple JWT Login – Login and Register to WordPress using JWT

"Simple JWT Login is a WordPress plugin that simplifies user login and registration using JWT. It offers secure, seamless entry to your site, enhancing user experience and site security."

★★★★★ (44) Active Installs: 2000+ Tested with: 6.3.2 PHP Version: 5.5
Included Shortcodes:
  • [simple-jwt-login:request]

Simple Jwt Login [simple-jwt-login:request] Shortcode

The Simple-JWT-Login shortcode is designed to retrieve a specific request parameter. It works by checking if a ‘key’ parameter is set. If not, it returns an empty string. If the ‘key’ parameter is set, it checks if this parameter exists in the global $_REQUEST array. If it does, it returns the sanitized value of the parameter, otherwise, it returns an empty string.

Shortcode: [simple-jwt-login:request]

Parameters

Here is a list of all possible simple-jwt-login:request shortcode parameters and attributes:

  • key – key-name of the requested data in the $_REQUEST array

Examples and Usage

Basic example – A simple usage of the shortcode to retrieve a request parameter by key.

[simple-jwt-login:request key="username" /]

This shortcode will return the value of the ‘username’ parameter from the request if it exists. If the ‘username’ parameter is not present in the request, the shortcode will return an empty string.

Advanced examples

Using the shortcode to retrieve multiple request parameters by their keys.

[simple-jwt-login:request key="username" /]
[simple-jwt-login:request key="password" /]

In this example, the shortcode is used twice to retrieve the ‘username’ and ‘password’ parameters from the request. Each shortcode will return the value of its respective parameter if it exists. If a parameter is not present in the request, the corresponding shortcode will return an empty string.

It’s important to note that the ‘key’ attribute in the shortcode corresponds to the key of the request parameter you want to retrieve. Therefore, you should replace ‘username’ or ‘password’ with the actual key of the parameter you are interested in.

PHP Function Code

In case you have difficulties debugging what causing issues with [simple-jwt-login:request] shortcode, check below the related PHP functions code.

Shortcode line:

add_shortcode('simple-jwt-login:request', 'simple_jwt_login_request_shortcode');

Shortcode PHP function:

function simple_jwt_login_request_shortcode($parameter = null)
{
    $parameter = $parameter !== null && isset($parameter['key'])
        ? $parameter['key']
        : null;

    if ($parameter === null) {
        return '';
    }

    /**
     * @SuppressWarnings(PHPMD.Superglobals)
     */
    if (!isset($_REQUEST[$parameter])) {
        return '';
    }

    return esc_html($_REQUEST[$parameter]);
}

Code file location:

simple-jwt-login/simple-jwt-login/simple-jwt-login.php

Conclusion

Now that you’ve learned how to embed the Simple Jwt Login Plugin shortcode, understood the parameters, and seen code examples, it’s easy to use and debug any issue that might cause it to ‘not work’. If you still have difficulties with it, don’t hesitate to leave a comment below.

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *