Ajii Noguerra Ajii Noguerra - 1 year ago 86
PHP Question

Create a wordpress login form to a non-wordpress website

I have two different websites. One is a non-wordpress website and the other one is blog made from wordpress framework. Is it possible to set up a login form to the non-wordpress site which redirects you to the wordpress blog dashboard if your login information is valid?

I tried creating a form in my website and set the action to my blog wp-login.php but instead of redirecting me to the dashboard it just displays the main wordpress login window but I am already logged in.

Answer Source

Use below form:

<form method="post" action="http://yourdomain.com/blog/wp-login.php" id="loginform" name="loginform">
        <label for="user_login">Username<br>
        <input type="text" size="20" value="" class="input" id="user_login" name="log"></label>
        <label for="user_pass">Password<br>
        <input type="password" size="20" value="" class="input" id="user_pass" name="pwd"></label>
    <p class="forgetmenot"><label for="rememberme"><input type="checkbox" value="forever" id="rememberme" name="rememberme"> Remember Me</label></p>
    <p class="submit">
        <input type="submit" value="Log In" class="button button-primary button-large" id="wp-submit" name="wp-submit">
        <input type="hidden" value="http://yourdomain.com/blog/wp-admin" name="redirect_to">
        <input type="hidden" value="1" name="testcookie">

Note: Replace http://yourdomain.com/blog/ with your actual blog url