0

I am trying to automatically populate/set the "Website" under Contact Information in user profiles at registration time. I want the URL to go to their Author Archives page (i.e., http://mywordpresssite.com/author/Tom/)

I am using the Paid Memberships Pro plugin for registration. I am also using Theme My Login if that makes any difference, but not for registration.

The code below doesn't work because it seems that the URL for the author posts hasn't been created yet. I have tried so many different things and now I'm stumped!

function change_user_url($user_id) {
        global $user_login;

        get_currentuserinfo();

        $display_name = $user_login;

        $website = get_author_posts_url();
        $website = $website . $display_name;  

        wp_update_user( array( 'ID' => $user_id, 'user_url' => $website ) );

    }
       add_action('user_register', 'change_user_url');

1 Answer 1

0

A few things come to mind...

1) Do users have to activate their accounts? If they do, it's quite possible that users who haven't activated yet are the users who don't return an author URL

2) If this is occurring for all users, that shouldn't matter since you already know what the expected URL is going to be.

<?php $author_url = bloginfo('url') . '/author/' . $display_name; ?>

Hope this helps. Good luck!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.