0
votes

first sorry for my english

i have a problem of redirect an user when he is connected , i make that on a custom login page (modal)

when i put to submit

i call this code in connexion.php

<?php
define('WP_USE_THEMES', false);  
require_once('../../../../wp-load.php');
global $qode_options_theme16;
global $wp_query;
global $wpdb;

// using ldap bind
$ldaprdn  = "cn=gazano,dc=cerpweb,dc=local";     // ldap rdn or dn
$ldappass = "test";  // associated password

// connect to ldap server
$ldapconn = ldap_connect("192.168.209.7","389")
    or die("Could not connect to LDAP server.");

ldap_set_option($ldapconn, LDAP_OPT_PROTOCOL_VERSION, 3);


if ($ldapconn) {

    // binding to ldap server
    $ldapbind = ldap_bind($ldapconn, $ldaprdn, $ldappass);

    // verify binding
    if ($ldapbind) {
        echo "LDAP bind successful...";
        $mdp = wp_hash_password('cerpcerp');

        $wpdb->query("INSERT INTO wp_users (user_login,user_pass, user_nicename, user_email, user_url, user_activation_key, user_status,display_name) VALUES ('hjhjh', '$mdp','e51511','[email protected]','15d15','ertre','0','jhjh')");

       $user=wp_authenticate('hjhjh', 'cerpcerp');

        $ie=wp_redirect(home_url());

        my_login_redirect( $ie,' ', '1' );


    } else {
        echo "LDAP bind failed...";
    }

}

?>

my Ldap works correctly , my insert Works as well and my wp_authenticate('hjhjh', 'cerpcerp'); works also,

but the problem is in my_login_redirect( $ie,' ', '1' )

the redirect in home works correctly but without connexion ...

and in my header.php a put this one

global $current_user;
$current_user = wp_get_current_user();

someone can help me

thank in advance

1

1 Answers

1
votes

As far as I remember you need to exit() right after wp_redirect.

You have also some filter to do it

add_filter( 'login_redirect', 'my_login_redirect', 10, 3 );