Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I have just a landing page at http: //mydomain.com, and webapp logic based on WP at http: //app.mydomain.com. How to place register form at http: //mydomain.com/dload/ to perform registration at subdomain http: //app.mydomain.com. Currently I am using iframe an it works well, but this solution is not friendly for google analytics. What I have:

<?php

add_action('wp_head', 'meta_redirect');

function meta_redirect()
{   
    $format = $_GET['format'];
    if(!empty($format)){
        echo '<meta http-equiv="refresh" content="3;url=http://download.mydomain.com/setup.'.$format.'"/>';
    }
}

get_header(); 
?>

<form method="post" action="http://app.mydomain.com/wp-login.php?action=register" class="wp-user-form" id="regform">
    <p class="username"><input type="text" name="user_login" required placeholder="login" value="" size="20" id="user_login" tabindex="101" /></p>
    <p class="email"><input type="email" name="user_email" required placeholder="mail@example.com" value="" size="25" title="Email will be used as a login if the option below is not picked" id="user_email" tabindex="102" /></p>
    <p><label><input id="toggle_login" type="checkbox"/>Use login, that differ from email</label></p>
    <p class="login_fields">
        <input type="submit" name="user-submit" value="Download" class="user-submit button button-primary" tabindex="103" /> in
                <select id="format">
                    <option value="zip">zip</option>
                    <option value="exe">exe</option>
                </select> 
                format
        <input type="hidden" id="redirect_to" name="redirect_to" value="http://mydomain.com/dload/" />
        <input type="hidden" name="user-cookie" value="1" />
    </p>
    <?php $register = $_GET['register']; if($register == true) { echo '<p>Success! Downloading will start in 3 seconds.</p>'; } ?>
</form>

<script type="text/javascript">
jQuery(function($){
    $('#regform .username').hide();
    $('#toggle_login').change(function(){
        if(this.checked){
            $('#regform .username').show();
            $("#user_login").val('');
        }else{
            $('#regform .username').hide();
            $("#user_login").val($("#user_email").val());
        }
    });
    $("#user_email").keyup(function(){
        $("#user_login").val($(this).val());
    });
    $('#regform').on('submit', function(){
        var str = $.param({ register:true, format:$('#format option:selected').val() });
        $('#redirect_to').val(function( index, val ){ return val + '?' + str});
    });
});
</script>

This code also performs registration at app.mydomain.com but brings me to *http: //app.mydomain.com/wp-login.php?redirect_to=http%3A%2F%2Fapp.mydomain.com%2Fwp-admin%2F&reauth=1* instead of http: //mydomain.com/dload/

share|improve this question
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.