WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Is there a way to redirect a user who logs in using wp_login_form to a custom page that is created automatically on signup

It seems like the URL needs to be absolute and obviously the end of the URL would change with each user.

Please see the function used to create the page on signup

function create_user_page($user_id) {
    if ( $user = get_userdata($user_id) ) {
        // Create a new user-specific page
        $page = array(
                'comment_status' => 'closed',
                'ping_status' => 'closed',
                'post_name' => $user->user_login,
                'post_status' => 'publish',
                'post_title' => $user->user_login,
                'post_type' => 'page'

So, when a user logs in via the page that includes wp_login_form they need to be redirected to http://www.websiteurl.com/user1 etc. where user1 is the page that has been created.

I hope that made sense.

share|improve this question

Yeah its pretty simple! I believe you already have the code to create a page in place. Like if we are using wp_insert_post() it will return the post ID on success. So you can do something like this:

$page_id = wp_insert_post( $args );
wp_redirect( get_permalink( $page_id ) );
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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