Skip to content

Instantly share code, notes, and snippets.

@adeel-raza
Last active December 13, 2023 16:02
Show Gist options
  • Save adeel-raza/680d23811088777343dda2e42d2e7384 to your computer and use it in GitHub Desktop.
Save adeel-raza/680d23811088777343dda2e42d2e7384 to your computer and use it in GitHub Desktop.
Uppercase First Name, Last Name or User Login Name on LearnDash LMS Certificates
add_filter( 'learndash_usermeta_shortcode_field_value_display', 'ee_learndash_usermeta_shortcode_field_value_display_callback', 10, 2 );
function ee_learndash_usermeta_shortcode_field_value_display_callback( $value, $attr ) {
global $post;
// Don't apply logic if not on a certificate
if ( isset( $post->post_type ) ) {
$is_certificate_page = $post->post_type;
if ( 'sfwd-certificates' != $is_certificate_page ) {
return $value;
}
}
$user_name_fields = array( 'user_login', 'first_last_name', 'nickname', 'user_nicename', 'display_name', 'first_name', 'last_name' );
if ( in_array( $attr['field'], $user_name_fields ) ) {
return strtoupper( $value );
}
return $value;
}
@adeel-raza
Copy link
Author

Place this snippet in your child theme's functions.php file

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment