llms_set_user_password_rest_key( int $user_id )
Generate a user password reset key, hash it, and store it in the database
Description Description
Parameters Parameters
- $user_id
-
(int) (Required) WP_User ID
Return Return
(string)
Source Source
File: includes/functions/llms.functions.person.php
function llms_set_user_password_rest_key( $user_id ) { $user = get_user_by( 'ID', $user_id ); // generate an activation key $key = wp_generate_password( 20, false ); do_action( 'retrieve_password_key', $user->user_login, $key ); // wp core hook // insert the hashed key into the db if ( empty( $wp_hasher ) ) { require_once ABSPATH . 'wp-includes/class-phpass.php'; $wp_hasher = new PasswordHash( 8, true ); } $hashed = $wp_hasher->HashPassword( $key ); global $wpdb; $wpdb->update( $wpdb->users, array( 'user_activation_key' => $hashed, ), array( 'user_login' => $user->user_login, ) ); return $key; }
Expand full source code Collapse full source code View on GitHub
Changelog Changelog
Version | Description |
---|---|
3.8.0 | Introduced. |
User Contributed Notes User Contributed Notes
Permalink: