A WordPress-centric search engine for devs and theme authors



wp_create_nonce ›

Since2.0.3
Deprecatedn/a
wp_create_nonce ( $action = -1 )
Parameters:
  • (string|int) $action Scalar value to add context to the nonce.
    Required: No
    Default: -1
Returns:
  • (string) The token.
Defined at:
Codex:
Change Log:
  • 4.0.0

Creates a cryptographic token tied to a specific action, user, user session, and window of time.



Source

function wp_create_nonce( $action = -1 ) {
		$user = wp_get_current_user();
		$uid  = (int) $user->ID;
		if ( ! $uid ) {
			/** This filter is documented in wp-includes/pluggable.php */
			$uid = apply_filters( 'nonce_user_logged_out', $uid, $action );
		}

		$token = wp_get_session_token();
		$i     = wp_nonce_tick();

		return substr( wp_hash( $i . '|' . $action . '|' . $uid . '|' . $token, 'nonce' ), -12, 10 );
	}
endif;

if ( ! function_exists( 'wp_salt' ) ) :