0

I'm trying to create a simple wordpress plugin that allows me to show the currently logged in User ID on a page by adding a shortcode. I think I have it figured out for the biggest part, except that I'm getting a parse error. Parse error: syntax error, unexpected '''' (T_CONSTANT_ENCAPSED_STRING), expecting ';' or ',' in ... on line 53

Below it the code in which it fails

    function uniqueID_shortcode() {

    ob_start();
    
    $user_id = get_current_user_id();
    
    if($user_id == 0){
        echo '<span class="unique-id">No ID available because there is no logged in user. Please log in.</span>';
    }
    
    else{
        echo '<span class="unique-id">'.$user_id'</span>';
    }

    return ob_get_clean();

add_shortcode( 'show-unique-id', 'uniqueID_shortcode' );

Line 53 is

echo '<span class="unique-id">'.$user_id'</span>';

Any help with this would be greatly appreciated! Thank you, Kenneth

0 Answers0