Shortcode for displaying the user’s first name?


Hi @silumant,

You can attempt a customized shortcode. Below’s an instance.


add_shortcode( 'my_first_name', feature ($ atts) {
$ current_user = wp_get_current_user();.
if (! ($ current_user instanceof WP_User)) return;.

$ atts = array_change_key_case( (selection) $atts, CASE_LOWER );.

essence( shortcode_atts( selection(.
' display_tag' => > 'h2',.
), $atts) );.

$ o='<< div course=" wporg-box">>';
$ t = $display_tag? $display_tag: 'h2';// Simply in situation.
$ o.= '<'. esc_html __( $current_user->> user_firstname). '<';.
$ o.= '<';.

return $o;.
} );.

Include this to your kid motif's functions.php documents or make use of a code fragments plugin.

Use: [my_first_name], [my_first_name display_tag="h1"]

Hope that assists