Home / Widgets / First Name Shortcode
Duplicate Snippet

Embed Snippet on Your Site

First Name Shortcode

Displays the user's first name with the [first_name] shortcode

<10
Code Preview
php
<?php
// Check if a user is logged in
if (is_user_logged_in()) {
    // Get the current user's information
    $current_user = wp_get_current_user();
    // Get the first name of the user
    $first_name = $current_user->first_name;
    // Check if the first name is not empty
    if (!empty($first_name)) {
        echo '' . $first_name . '';
    } else {
        echo '';
    }
} else {
    echo '';
}
?>

Comments

Add a Comment