Get current users post URL?

Well if your code is working properly and the only problem is that it displays when no one is logged in then try the code below. Because right now you are saying “Hey WP just echo out this” – so it does it. You need to change it to: “Hey WP if the user is logged in show the link to his page and if not show the login link” like that:

<?php
    if ( is_user_logged_in() ) {
        echo '<a href="' . home_url() . '/author/' . get_the_author_meta( 'user_login', wp_get_current_user()->ID ) . '"> My personal page</a>';
    } else {
        echo '<a href="' . wp_login_url() . '" title="Login">Login</a>';
    }
?>

Now to address the problem with user names with spaces you could try this code:

<?php
    if ( is_user_logged_in() ) {
        global $current_user;
        get_currentuserinfo();
        echo '<a href="' . get_author_posts_url($current_user->ID) . '"> My personal page</a>';
    } else {
        echo '<a href="' . wp_login_url() . '" title="Login">Login</a>';
    }
?>

Reference:

Leave a Comment