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.

My issue is that i have a custom login (and registration) form on each of my wordpress multisites (all blog are on subdomains). But only on the main domain it passes and logging me in (as well registration. after register new user it logging me in).

But on the other site (somesite.domain.com) it doesn't logging me in. The registration process is going perfect but in the end it doesn't logged me in either.

Below is my code for logging process.

$saveSess = session_encode(); // i'm saving all my session vars
include_once($_SERVER['DOCUMENT_ROOT'].'/wp-load.php' );
session_decode($saveSess); // i'm getting back all my session vars
global $wpdb;

$pass   = $_POST["pas"];
$mail   = $_POST["log"];

$autentyk = dr_email_login_authenticate(null, $mail, $pass); // plugin action to log in with email, not username
if (is_wp_error($autentyk)) {
    $_SESSION["user_logged"] = false;
} else {
    $login = $autentyk->data->user_login;

    wp_clear_auth_cookie();

    $creds = array();
    $creds['user_login'] = $login;
    $creds['user_password'] = $pass;
    $creds['remember'] = true;
    $user = wp_signon($creds, false);

    if (is_wp_error($user)) {
        $error = $user->get_error_message();
    } else {
        wp_set_current_user($autentyk->ID);
        wp_set_auth_cookie($autentyk->ID, true);
        do_action('set_current_user');
        $current_user = wp_get_current_user();
        if (is_wp_error($current_user)) {
            $error = $user->get_error_message();
        } else {
            // some actions
        }
    }

    if ($error) {
    }
}

i'm doing this login and registration with ajax but as i said: on the main domain blog it goes perfect. many thanks in advance for your support in this case.

I have also set define('COOKIE_DOMAIN', '.yourdomain.com'); in my wp-config.php

share|improve this question
1  
Problem is over. I changed all ajax scripts to inner wordpress ajax. here's how: w4dev.com/wp/wp_ajax –  Kamil Jul 12 '13 at 14:28
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.