From d14218fcd38369ca4870b636fa0ca9ec539a95c2 Mon Sep 17 00:00:00 2001 From: Andrew Nacin Date: Thu, 11 Mar 2010 18:28:31 +0000 Subject: [PATCH] Add delete_user_option(). fixes #12573, props TobiasBg. git-svn-id: https://develop.svn.wordpress.org/trunk@13667 602fd350-edb4-49c9-b593-d223f7449a82 --- wp-includes/user.php | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/wp-includes/user.php b/wp-includes/user.php index 253419feef..7c5ab5c02f 100644 --- a/wp-includes/user.php +++ b/wp-includes/user.php @@ -268,7 +268,7 @@ function get_user_option( $option, $user = 0, $deprecated = '' ) { * @param int $user_id User ID * @param string $option_name User option name. * @param mixed $newvalue User option value. - * @param bool $global Optional. Whether option name is blog specific. + * @param bool $global Optional. Whether option name is global or blog specific. Default false (blog specific). * @return unknown */ function update_user_option( $user_id, $option_name, $newvalue, $global = false ) { @@ -279,6 +279,29 @@ function update_user_option( $user_id, $option_name, $newvalue, $global = false return update_user_meta( $user_id, $option_name, $newvalue ); } +/** + * 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 'global' parameter is false, which it is by default + * it will prepend the WordPress table prefix to the option name. + * + * @since 3.0.0 + * @uses $wpdb WordPress database object for queries + * + * @param int $user_id User ID + * @param string $option_name User option name. + * @param bool $global Optional. Whether option name is global or blog specific. Default false (blog specific). + * @return unknown + */ +function delete_user_option( $user_id, $option_name, $global = false ) { + global $wpdb; + + if ( !$global ) + $option_name = $wpdb->prefix . $option_name; + return delete_user_meta( $user_id, $option_name ); +} + /** * Get users for the blog. *