delete_user_option()WP 3.0.0

Delete user option with global blog capability.

User options are just like user metadata except that they have support for global blog options. If the 'is_global' parameter is false, which it is by default, it will prepend the WordPress table prefix to the option name.

No Hooks.

Return

true|false. True on success, false on failure.

Usage

delete_user_option( $user_id, $option_name, $is_global );
$user_id(int) (required)
User ID
$option_name(string) (required)
User option name.
$is_global(true|false)
Whether option name is global or blog specific.
Default: false (blog specific)

Examples

0

#1 Delete the metadata default_password_nag of the user with ID=8:

if( delete_user_option( 8, 'default_password_nag' ) )
	echo "the default_password_nag option has been removed!";
else
	echo "failed to remove the default_password_nag option!";

Notes

  • Global. wpdb. $wpdb WordPress database abstraction object.

Changelog

Since 3.0.0 Introduced.

delete_user_option() code WP 6.4.3

function delete_user_option( $user_id, $option_name, $is_global = false ) {
	global $wpdb;

	if ( ! $is_global ) {
		$option_name = $wpdb->get_blog_prefix() . $option_name;
	}

	return delete_user_meta( $user_id, $option_name );
}