TOC

Plugin Features

The “Certificate Verifier for LearnDash” plugin offer two features to validate certificate IDs. These include:

  • A form submission option where the certificate ID can be entered and submitted for validation.
  • A URL query option where the certificate ID can be included in the URL and validated upon page loading, eliminating the need to enter the certificate ID into a form field.

Additionally, the plugin offers two options for displaying the validation information:

  • A preformatted HTML tablelist or div that are mobile-friendly.
  • A page editor design option that allows for greater flexibility in the formatting and order of the output using shortcodes. However, this option requires knowledge of how to design mobile-friendly pages and style rendered shortcodes.

Shortcode: Certificate ID Search (self-closing)

[elc_ssc_front_search]

The above shortcode is used to generate a form for searching a certificate ID. The form rendered by this shortcode contains two elements:

  • A text field for inputting the certificate ID.
  • A search (submit) button.

Shortcode Parameters

datetime_format (optional), default “Y-m-d”.

Format for completion and expiry date fields. If used allows to override default format. 

For example, if you want to display the date in the format of “F j, Y” you can use the following shortcode:

[elc_ssc_front_search datetime_format=”F j, Y”]

By default the dates are formatted as ‘YYYY-mm-dd’ e.g. 2023-01-24. The example above will format the all dates in the output as ‘{full month name} {day}, {year}’

e.g.: January 24, 2023.

display_as (optional)

Supported values: table (defualt), list, div.
Note: This parameter takes effect only with self-closing shortcode.

Example:

If you want to display the verification information in a list, you can use the following shortcode:

[elc_ssc_front_search display_as=”list”]

If you want to display the verification information in a div, you can use the following shortcode:

[elc_ssc_front_search display_as=”div”]

Certificate ID Search (opening and closing)

The shortcode[elc_ssc_front_search] renders the search form, which includes a certificate ID input text field and a search (submit) button. This shortcode allows you to insert other shortcodes within it, which will be rendered inside the search output. The layout and decorations of the search output will depend on how the verification page is formatted.

Example:

[elc_ssc_front_search]
<!-- Content to be included in search output BEGIN -–>
[other_shortcode_one]
[other_shortcode_two] …
<!-- Content to be included in search output END -–>
[/elc_ssc_front_search]

In the above example, the opening shortcode [elc_ssc_front_search] renders the search form in the same way as before, and any other shortcodes (e.g. other_shortcode_one, other_shortcode_two) that are inserted between the opening and closing shortcode [/elc_ssc_front_search], will be rendered within the search output (verification information).

In summary, this shortcode renders the search form and allows the user to insert other shortcodes within it, which will be rendered inside the search output.

Shortcode [elc_ssc_show]

This following shortcode displays the label and value for a specified field saved along with the certificate ID.

Shortcode Parameters

show(required).

Supported values: post_title, course_title, completion_date, epiry_date


post_title

Displays the title of the quiz, course, or group for which the certificate was issued
[elc_ssc_show show=”post_title”]

course _title

Displays the title of the course to which the quiz is associated with. This is only rendered if the certificate is for a quiz.
[elc_ssc_show show=”course_title”]

completion_date

Displays the formatted completion date of the quiz/course/group. The date format is determined by the “datetime_format” parameter in the elc_ssc_front_search shortcode.

[elc_ssc_show show=”completion_date”]

expiry_date

Displays the formatted expiry date of the quiz/course/group. The date format is determined by the “datetime_format” parameter in the elc_ssc_front_search shortcode.

[elc_ssc_show show=”expiry_date”]

usermeta

Displays first or last name of the user for whom certificate was issued. 

To display first name use following shortcode:
[elc_ssc_show show=”usermeta” field=”first_name”]

To display last name use following shortcode:
[elc_ssc_show show=”usermeta” field=”last_name”]

Note: When show=”usermeta” is used, the field=”first_name” or field=”last_name” is required. 


label (optional)

If label is not used the shortcode will output just the field value e.g.:

[elc_ssc_show show=”post_title”]

Above will display:
Assessment Test Quiz 1


If label is used the shorcode will output default label and quiz title.

[elc_ssc_show show=”post_title” label]

Above will display:
Quiz Title: Assessment Test Quiz 1

If label is used and has a value, this value will overirde the default label.

[elc_ssc_show show=”post_title” label=”QUIZ”]

Above will display:
QUIZ: Assessment Test Quiz 1


Example : If using all of it together: 

[elc_ssc_front_search datetime_format=”F j, Y”]
<!– ELearningComplete Certificate ID Show shortcode -–>
[elc_ssc_show show=”usermeta” field=”first_name”]
<!– ELearningComplete Certificate ID Show shortcode -–>
[elc_ssc_show show=”usermeta” field=”last_name”]
<!– ELearningComplete Certificate ID Show shortcode -–>
[elc_ssc_show show=”course_title” course_id=”{$course_id}” post_id=”{$post_id}”]
<!– ELearningComplete Certificate ID Show shortcode -–>
[elc_ssc_show show=”post_title” post_id=”{$post_id}”]
<!– ELearningComplete Certificate ID Show shortcode -–>
[elc_ssc_show show=”completion_date” completion_date=”{$completion_date}”]
<!– ELearningComplete Certificate ID Show shortcode -–>
[elc_ssc_show show=”expiry_date” expiry_date=”{$expiry_date}”]
[/elc_ssc_front_search]


The above example demonstrates how to use the shortcodes provided by the Certificate Verifier plugin in combination with variables exposed by the plugin. The shortcodes, [elc_ssc_front_search][usermeta], and [elc_ssc_show], are used to display information such as the user’s first and last name, the quiz or course or group title, the completion date, and the expiry date. The shortcode [elc_ssc_front_search] can take an optional parameter, “datetime_format”, which allows for the formatting of the completion and expiry date fields.

Note:
The above example exposes variables:
$user_id, $post_id, $completion_date, $expiry_date, $course_id

The exposed variable are enclosed in curly braces and can be used in conjunction with the shortcodes to display specific information.

Enclosing the variables in curly braces tells the plugin that these are placeholders that need to be replaced with actual values before the shortcode is rendered.

The Certificate Verifier for LearnDash plugin implements following hooks that can be used in PHP snippets or in current theme functions.php

Hooks

elc_ctid_verifier_alter_username
Filter Hook: Filters user first or last name. Can be used to obscure (obfuscate) user first and/or last name with ‘*’, similar to password field being obscured. See example below.

Example:
/**
 * Snippet for 'elc_ctid_verifier_alter_username' filter hook.
 * Plugin: Certificate Verifier for LearnDash
 * Requires ersion: 2.3 (for now)
 */
add_filter( 'elc_ctid_verifier_alter_username',
    function ( $s ) {
        // First and/or last name can use more than one word.
        // We split the first/last to separate words
        // and then obfuscate the parts.
        // E.g. 'Daan Van den Berg' will return 'D*** V** d** B***'.
        //
        $split_pattern = '/[\n\r\t\v\s]/';
        $parts         = preg_split( $split_pattern, $s );

        // Obfuscate the first/last name except the first letter.
        $replace_pattern = '/(?<!^)\S/';
        $tmp             = '';
        foreach ( $parts as $val ) {
            $tmp .= preg_replace( $replace_pattern, '*', trim( $val ) ) . ' ';
        }
        $s = trim( $tmp );

        // Always return $s.
        return $s;
    }
);
Scroll to Top