Ejemplo n.º 1
0
/**
 * Delete all customer meta for a certain customer ID.
 *
 * Implement your own system by hooking into 'wpsc_delete_all_customer_meta'.
 *
 * @since  3.8.9.4
 * @param  string|int $id Customer ID. Optional. Defaults to current customer
 * @return boolean        True if successful, False if otherwise
 */
function wpsc_delete_all_customer_meta($id = false)
{
    global $wpdb;
    if (!$id) {
        $id = wpsc_get_current_customer_id();
    }
    $result = apply_filters('wpsc_delete_all_customer_meta', null, $id);
    if ($result) {
        return $result;
    }
    $meta = wpsc_get_all_customer_meta($id);
    $success = false;
    foreach ($meta as $key => $value) {
        $success = wpsc_delete_visitor_meta($id, $key);
    }
    return $success;
}
Ejemplo n.º 2
0
/**
 * Delete customer meta.
 *
 * @access public
 * @since  3.8.9
 * @param  string     $key  Meta key
 * @param  string|int $id   Customer ID. Optional. Defaults to current customer.
 * @return boolean|WP_Error True if successful. False if not successful. WP_Error
 *                          if there are any errors.
 */
function wpsc_delete_customer_meta($key, $id = false)
{
    $profile = wpsc_get_all_customer_meta($id);
    if (is_wp_error($profile)) {
        return $profile;
    }
    if (array_key_exists($key, $profile)) {
        unset($profile[$key]);
    }
    return wpsc_update_all_customer_meta($profile, $id);
}