From b1af79fb05c65bc3bcad1fca65236c762effc2d7 Mon Sep 17 00:00:00 2001 From: ryan Date: Thu, 13 Apr 2006 04:49:38 +0000 Subject: [PATCH] Add wp_revoke_user() and WP_User::remove_all_caps() to help those doing multi blog stuff. git-svn-id: http://svn.automattic.com/wordpress/trunk@3705 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-admin/admin-db.php | 7 +++++++ wp-includes/capabilities.php | 8 ++++++++ 2 files changed, 15 insertions(+) diff --git a/wp-admin/admin-db.php b/wp-admin/admin-db.php index 41131a4934..77e8db5e5c 100644 --- a/wp-admin/admin-db.php +++ b/wp-admin/admin-db.php @@ -274,6 +274,13 @@ function wp_delete_user($id, $reassign = 'novalue') { return true; } +function wp_revoke_user($id) { + $id = (int) $id; + + $user = new WP_User($id); + $user->remove_all_caps(); +} + function get_link($link_id, $output = OBJECT) { global $wpdb; diff --git a/wp-includes/capabilities.php b/wp-includes/capabilities.php index 22aed044cf..ea571cbc42 100644 --- a/wp-includes/capabilities.php +++ b/wp-includes/capabilities.php @@ -232,6 +232,14 @@ class WP_User { update_usermeta($this->id, $this->cap_key, $this->caps); } + function remove_all_caps() { + global $wpdb; + $this->caps = array(); + update_usermeta($this->id, $this->cap_key, ''); + update_usermeta($this->id, $wpdb->prefix.'user_level', ''); + $this->get_role_caps(); + } + //has_cap(capability_or_role_name) or //has_cap('edit_post', post_id) function has_cap($cap) {