Ajii Noguerra Ajii Noguerra - 4 months ago 9
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

Use below form:

<form method="post" action="http://yourdomain.com/blog/wp-login.php" id="loginform" name="loginform">
    <p>
        <label for="user_login">Username<br>
        <input type="text" size="20" value="" class="input" id="user_login" name="log"></label>
    </p>
    <p>
        <label for="user_pass">Password<br>
        <input type="password" size="20" value="" class="input" id="user_pass" name="pwd"></label>
    </p>
    <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">
    </p>
</form>

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