javascriptwordpressauthenticationform-fields

Populate wp-login field with JavaScript


So on the wordpress login page of my site I want to have two buttons below the login box, each button containing login info for specific user. Admin and demo. How can I accomplish this with JavaScript and where would I throw the buttons, wp-login.php? Thanks for your help.


Solution

  • One option is to implement some sort of hook on wordpress

    More details on: http://codex.wordpress.org/Plugin_API/Action_Reference/login_form

    Using this hook you can add another buttons as html or javascript code

    add_action('login_form','login_extra_buttons');
    
    function login_extra_buttons() {
    
        ?>
        <a href="#" onclick="$('#user_login').value = 'demo';$('#user_pass').value = 'demo';">Demo Login</a>
        <a href="#" onclick="$('#user_login').value = 'admin'; $('#user_pass').value = 'demo';">Admin Login</a>
    
        <?php
    }