Pass variable from URL through a php login redirect function into wp-login form inputs


Staff member
This is a funny one, but only a genius can probably figure this out. It's an odd one.

Requires a little javascript and a little adjustment to my existing php wordpress function.

I have a wp site that is locked down from the public using this function...

add_action('get_header', 'wpq_member_only_site');
function wpq_member_only_site() {

    if ( !is_user_logged_in() ) {

        $redirect_after_login = get_home_url();

        $login_url = wp_login_url( $redirect_after_login );

        wp_redirect( $login_url, 302 );


...which redirects non-logged in users to the login form.

My question is, I would like use URL variables like this...


...and somehow, (I guess) pass it through the function and into the login page URL...

<strong>;user=media&amp;password=23747</strong> then a script in my login_head can use, and automatically pre-populate the login form.

I will insert the script into my login_head using this function...

function my_login_head() {
  echo '

      &lt;!-- script here --&gt;
add_action('login_head', 'my_login_head');

Does anyone think they can help me with this? Or know if its possible.

The idea is, so I can use this URL to give people access without them having to know the username or password.

Any ideas or help would be awesome, thanks!