delete_user_setting

Advertisement

Summery Summery

Deletes user interface settings.

Syntax Syntax

delete_user_setting( string $names )

Description Description

Deleting settings would reset them to the defaults.

This function has to be used before any output has started as it calls setcookie().

Parameters Parameters

$names

(Required) The name or array of names of the setting to be deleted.

Return Return

(bool|null) True if deleted successfully, false if not. Null if the current user can't be established.

Source Source

File: wp-includes/option.php

	$user_id = get_current_user_id();
	if ( ! $user_id ) {
		return;
	}

	if ( ! is_user_member_of_blog() ) {
		return;
	}

	$settings = (string) get_user_option( 'user-settings', $user_id );

	if ( isset( $_COOKIE[ 'wp-settings-' . $user_id ] ) ) {
		$cookie = preg_replace( '/[^A-Za-z0-9=&_]/', '', $_COOKIE[ 'wp-settings-' . $user_id ] );

		// No change or both empty.
		if ( $cookie == $settings ) {
			return;
		}

		$last_saved = (int) get_user_option( 'user-settings-time', $user_id );
		$current    = isset( $_COOKIE[ 'wp-settings-time-' . $user_id ] ) ? preg_replace( '/[^0-9]/', '', $_COOKIE[ 'wp-settings-time-' . $user_id ] ) : 0;

Advertisement

Changelog Changelog

Changelog
Version Description
2.7.0 Introduced.

Advertisement

Leave a Reply