Leave a Reply

1 comment

  1. There are ways to trick WP into pre-populating the username field, but I’m pretty sure it would involve using POST and also tricking it into thinking there were errors in a previous submission.

    My advice would be to just use Javascript (or jQuery, as I’ve done below). It’s still ‘hacky’, but at least it gets the job done with very little overhead and it’s dead easy to use. It adds a little script that checks for the prepopulate URL parameter, and triggers autocompletion if it finds anything.

    // Add jQuery if prepopulate GET is found
    add_action('login_head', 'prepopulate_username_js');
    function prepopulate_username_js() {
        if(isset($_GET['prepopulate'])) :
        ?>
        <script type="text/javascript">
            jQuery(function($){
                $('#user_login').val('<?php echo($_GET['prepopulate']); ?>');
            });
        </script>
        <?php
            endif;
    }
    

    Then, when creating the links on the logos, simply use something along these lines in your theme’s templates to trigger the script above:

    <a href="<?php echo(add_query_arg(array('prepopulate' => 'bob'), wp_login_url())); ?>">This will link to a prepopulated login form!</a> // change 'bob' for whatever is relevant