Save variable "user_pass" in WordPress and then call it

0

I have a question regarding the variable "user_pass", which momentarily contains the unencrypted password of the user who registers. Which I'm looking at is codex page . I want to save that password without encrypting it in the database and then calling it from a function, but I'm not sure how to do it.

Code sample (line 1420):

// hashed in wp_update_user(), plaintext if called directly
    $user_pass = ! empty( $userdata['user_pass'] ) ? $userdata['user_pass'] : $old_user_data->user_pass;
} else {
    $update = false;
    // Hash the password
    $user_pass = wp_hash_password( $userdata['user_pass'] );
}

Any suggestions are grateful.

    
asked by 29.03.2017 в 14:50
source

2 answers

0

In the end, my function has remained this way:

//ENVIAR DATOS DE NUEVOS USUARIOS REGISTRADOS AL SISTEMA DE ABSTRACTS EXTERNO
function shapeSpace_register_add_meta($user_id) { //Verificar el inicio de sesión por primera vez de un usuario
	add_user_meta($user_id, '_new_user', '1');
}
add_action('user_register', 'shapeSpace_register_add_meta');

function shapeSpace_first_user_login($user_login, $user) { //Comprobar si el usuario inicia sesión por primera vez
	$new_user = get_user_meta($user->ID, '_new_user', true);
	if ($new_user) {
		update_user_meta($user->ID, '_new_user', '0');

		$current_user = wp_get_current_user();

		$titulo = $current_user->title;
		$nombre = $current_user->user_firstname;
		$apellido = $current_user->user_lastname;
		$institucion = $current_user->institution;
		$direccion = $current_user->addr1;
		$ciudad = $current_user->city;
		$pais = $current_user->country;
		$correo = $current_user->user_email;
		$correo_anterior = $correo;

		//Obtener contraseña antes de que sea encriptada

        $user_pass = ! empty($userdata['user_pass']) ?
        $userdata['user_pass'] : $old_user_data->user_pass;
        $pass_no_encriptada = $userdata['user_pass'];

        //Comprobar campos que pueden estar vacíos

		if (empty($titulo)) {
				$titulo = "Mr";
		}

		if (empty($institucion)) {
				$institucion = "Unknown institution";
		}

		if (empty($ciudad)) {
				$ciudad = "Unknown city";
		}

        //Creación de las URL con datos del usuario

		$url_registro = "http://isha2017.mundodecongresos.com/add_registered_user.asp?title=" .$title. "&first_name=" .$nombre. "&&last_name=" .$apellido. "&institution=" .$institucion. "&address=" .$direccion. "&city=" .$ciudad. "&country=" .$pais. "&email=" .$correo. "&password=" .$pass_no_encriptada. "&previous_email=" .$correo_anterior;
		$url_acceso = "http://isha2017.mundodecongresos.com/login_integration.asp?email=" .$correo. "&password=" .$pass_no_encriptada;

		//Gatillar las URL

        shell_exec($url_registro);
        shell_exec($url_acceso);

	}
}
add_action('wp_login', 'shapeSpace_first_user_login', 10, 2);

Now I just have to test it.

    
answered by 30.03.2017 в 17:22
0

I recommend that you put your function as follows:

function shapeSpace_register_add_meta($user_id) {
    if ( isset( $_POST['user_pass'] ) )
        update_user_meta($user_id, 'user_pass_plano', $_POST['user_pass']);
}
add_action('user_register', 'shapeSpace_register_add_meta');
    
answered by 31.03.2017 в 00:39