Make “Add New User” redirect to user's profile

I'm wondering if it's possible that when you create a new user user-new.php you're being redirect to the user's profile instead of to users.php

I'm having some custom fields who only show up when you edit a user, so to make the workflow more easy I would like that the admin gets redirect to the user's profile so he can add those custom fields instantly.


wp_redirect is filterable, so you could hook in to redirect after a user was successfully added. I tested the following, might need a few tweaks but it does the trick:

add_filter( 'wp_redirect', 'wp_redirect_after_user_new', 1, 1 );
function wp_redirect_after_user_new( $location )
    global $pagenow;

    if( is_admin() && 'user-new.php' == $pagenow )
        $user_details = get_user_by( 'email', $_REQUEST[ 'email' ] );
        $user_id = $user_details->ID;

        if( $location == 'users.php?update=add&id=' . $user_id )
            return add_query_arg( array( 'user_id' => $user_id ), 'user-edit.php' );

    return $location;

Need Your Help

Finding index of a pandas DataFrame value

python python-2.7 pandas

I am trying to process some .csv data using pandas, and I am struggling with something that I am sure is a rookie move, but after spending a lot of time trying to make this work, I need your help.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.