For developers who require customization beyond standard shortcode parameters, the plugin provides hooks for styling the output with CSS and altering data with PHP. These advanced techniques offer a deeper level of control over the verification system’s appearance and functionality.
Styling the Search Form with Custom CSS #
Apply custom CSS to target the elements of the verification form and its output. Add the following snippet to your theme’s stylesheet or a custom CSS plugin to alter the appearance of the search form.
/*Certificate Tracker*/
.certificate-tracker {
text-align: center;
}
.certificate-tracker #search_by_id_th {
margin-bottom: 20px;
}
input#search_by_id {
border-radius: 5px;
border: solid 1px rgba(0,0,0,.2);
border-style: solid;
margin: 10px;
width: 100%;
max-width: 300px;
text-align: center;
color: #313131;
}
This CSS centers the form (.certificate-tracker), adds space below the title (#search_by_id_th), and applies custom styling to the search input field (input#search_by_id).
Obfuscating User Data with a PHP Filter Hook #
In scenarios where user privacy is a concern, you may need to obfuscate personally identifiable information. Use the elc_ctid_verifier_alter_username filter hook to programmatically intercept and modify a user’s first or last name before it is displayed.
This is particularly useful for obscuring full names while still confirming a partial match. Add the following PHP snippet to your theme’s functions.php file or a custom plugin to achieve this.
/**
* Snippet for 'elc_ctid_verifier_alter_username' filter hook.
* Plugin: Certificate Verifier for LearnDash
* Requires version: 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.
// Editor's Note: The source documentation contains a truncated regular
// expression. The pattern below reflects the presumed correct and
// functional version.
$replace_pattern = '/(?!^)./u';
$tmp = '';
foreach ( $parts as $val ) {
$tmp .= preg_replace( $replace_pattern, '*', trim( $val ) ) . ' ';
}
$s = trim( $tmp );
// Always return $s.
return $s;
}
);
This code splits a name into its component parts (e.g., ‘Daan Van den Berg’) and replaces all but the first letter of each part with an asterisk, resulting in an obfuscated output like ‘D*** V** d** B***’.
By combining a flexible shortcode system with powerful developer hooks, the LearnDash Certificate Verifier provides a comprehensive toolkit for building a verification system that precisely meets your project’s needs.