wpseek.com
Eine auf WordPress spezialiserte Suchmaschine für Entwickler und Theme-Autoren



wp_set_password › WordPress Function

Seit2.5.0
Veraltetn/v
wp_set_password ( $password, $user_id )
Parameter: (2)
  • (string) $password The plaintext new user password.
    Erforderlich: Ja
  • (int) $user_id User ID.
    Erforderlich: Ja
Definiert in:
Codex:

Updates the user's password with a new encrypted one.

For integration with other applications, this function can be overwritten to instead use the other package password checking algorithm. Please note: This function should be used sparingly and is really only meant for single-time application. Leveraging this improperly in a plugin or theme could result in an endless loop of password resets if precautions are not taken to ensure it does not execute on every page load.


Quellcode

function wp_set_password( $password, $user_id ) {
		global $wpdb;

		$hash = wp_hash_password( $password );
		$wpdb->update(
			$wpdb->users,
			array(
				'user_pass'           => $hash,
				'user_activation_key' => '',
			),
			array( 'ID' => $user_id )
		);

		clean_user_cache( $user_id );

		/**
		 * Fires after the user password is set.
		 *
		 * @since 6.2.0
		 *
		 * @param string $password The plaintext password just set.
		 * @param int    $user_id  The ID of the user whose password was just set.
		 */
		do_action( 'wp_set_password', $password, $user_id );
	}
endif;

if ( ! function_exists( 'get_avatar' ) ) :
	/**
	 * Retrieves the avatar `<img>` tag for a user, email address, MD5 hash, comment, or post.
	 *
	 * @since 2.5.0
	 * @since 4.2.0 Added the optional `$args` parameter.
	 * @since 5.5.0 Added the `loading` argument.
	 * @since 6.1.0 Added the `decoding` argument.
	 * @since 6.3.0 Added the `fetchpriority` argument.
	 *
	 * @param mixed  $id_or_email   The avatar to retrieve. Accepts a user ID, Gravatar MD5 hash,
	 *                              user email, WP_User object, WP_Post object, or WP_Comment object.
	 * @param int    $size          Optional. Height and width of the avatar in pixels. Default 96.
	 * @param string $default_value URL for the default image or a default type. Accepts:
	 *                              - '404' (return a 404 instead of a default image)
	 *                              - 'retro' (a 8-bit arcade-style pixelated face)
	 *                              - 'robohash' (a robot)
	 *                              - 'monsterid' (a monster)
	 *                              - 'wavatar' (a cartoon face)
	 *                              - 'identicon' (the "quilt", a geometric pattern)
	 *                              - 'mystery', 'mm', or 'mysteryman' (The Oyster Man)
	 *                              - 'blank' (transparent GIF)
	 *                              - 'gravatar_default' (the Gravatar logo)
	 *                              Default is the value of the 'avatar_default' option,
	 *                              with a fallback of 'mystery'.
	 * @param string $alt           Optional. Alternative text to use in the avatar image tag.
	 *                              Default empty.
	 * @param array  $args {
	 *     Optional. Extra arguments to retrieve the avatar.
	 *
	 *     @type int          $height        Display height of the avatar in pixels. Defaults to $size.
	 *     @type int          $width         Display width of the avatar in pixels. Defaults to $size.
	 *     @type bool         $force_default Whether to always show the default image, never the Gravatar.
	 *                                       Default false.
	 *     @type string       $rating        What rating to display avatars up to. Accepts:
	 *                                       - 'G' (suitable for all audiences)
	 *                                       - 'PG' (possibly offensive, usually for audiences 13 and above)
	 *                                       - 'R' (intended for adult audiences above 17)
	 *                                       - 'X' (even more mature than above)
	 *                                       Default is the value of the 'avatar_rating' option.
	 *     @type string       $scheme        URL scheme to use. See set_url_scheme() for accepted values.
	 *                                       Default null.
	 *     @type array|string $class         Array or string of additional classes to add to the img element.
	 *                                       Default null.
	 *     @type bool         $force_display Whether to always show the avatar - ignores the show_avatars option.
	 *                                       Default false.
	 *     @type string       $loading       Value for the `loading` attribute.
	 *                                       Default null.
	 *     @type string       $fetchpriority Value for the `fetchpriority` attribute.
	 *                                       Default null.
	 *     @type string       $decoding      Value for the `decoding` attribute.
	 *                                       Default null.
	 *     @type string       $extra_attr    HTML attributes to insert in the IMG element. Is not sanitized.
	 *                                       Default empty.
	 * }
	 * @return string|false `<img>` tag for the user's avatar. False on failure.
	 */