本文整理汇总了PHP中get_super_admins函数的典型用法代码示例。如果您正苦于以下问题:PHP get_super_admins函数的具体用法?PHP get_super_admins怎么用?PHP get_super_admins使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_super_admins函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: ure_is_admin
function ure_is_admin( $user_id = false ) {
global $current_user;
if ( ! $user_id ) {
if (empty($current_user) && function_exists('get_currentuserinfo')) {
get_currentuserinfo();
}
$user_id = ! empty($current_user) ? $current_user->ID : 0;
}
if ( ! $user_id )
return false;
$user = new WP_User($user_id);
$simpleAdmin = ure_has_administrator_role($user_id);
if ( is_multisite() ) {
$super_admins = get_super_admins();
$superAdmin = is_array( $super_admins ) && in_array( $user->user_login, $super_admins );
} else {
$superAdmin = false;
}
return $simpleAdmin || $superAdmin;
}
示例2: setUp
protected function setUp()
{
static::$redirect_to = null;
$admins = get_super_admins();
$user = get_user_by('login', $admins[0]);
if (is_wp_error($user) || !$user) {
throw new \Exception('Could not login.');
}
wp_set_current_user($user->ID);
}
示例3: wphsau_views_users
function wphsau_views_users($views)
{
foreach ($views as $key => $view) {
if ('all' == $key || 'administrator' == $key) {
$views[$key] = preg_replace_callback('/\\(([^()]*)\\)/', function ($matches) {
$super_admins = get_super_admins();
$super_admin_count = count($super_admins);
return '(' . (intval($matches[1]) - $super_admin_count) . ')';
}, $view);
}
}
return $views;
}
示例4: dashboard_signups
public function dashboard_signups()
{
global $gMemberNetwork;
$query = new \WP_User_Query(array('blog_id' => 0, 'orderby' => 'registered', 'order' => 'DESC', 'number' => 12, 'fields' => array('ID', 'display_name', 'user_email', 'user_registered', 'user_login')));
if (empty($query->results)) {
_ex('No User?!', 'Signup Admin Widget', GMEMBER_TEXTDOMAIN);
} else {
echo '<table class="widefat gmember-dashboard -table-signup"><thead><tr>';
echo '<th>' . _x('On', 'Signup Admin Widget', GMEMBER_TEXTDOMAIN) . '</th>';
echo '<th>' . _x('Name', 'Signup Admin Widget', GMEMBER_TEXTDOMAIN) . '</th>';
echo '<th>' . _x('E-mail', 'Signup Admin Widget', GMEMBER_TEXTDOMAIN) . '</th>';
echo '</tr></thead>';
$last = FALSE;
$alt = TRUE;
$template = '<tr%1$s>' . '<td class="-month-day" title="%5$s">%4$s</td>' . '<td class="-edit-link"><a title="%8$s" href="%6$s" target="_blank">%2$s</a></td>' . '<td class="-mail-link"><a title="%7$s" href="%7$s" target="_blank">%3$s</a></td>' . '</tr>';
foreach ($query->results as $user) {
$registered = strtotime(get_date_from_gmt($user->user_registered));
vprintf($template, array($alt ? ' class="alternate"' : '', esc_html($user->display_name), esc_html(gPluginTextHelper::truncateString($user->user_email, 32)), esc_html($gMemberNetwork->getDate($registered, 'monthday')), esc_attr(human_time_diff($registered) . ' — ' . $gMemberNetwork->getDate($registered)), get_edit_user_link($user->ID), 'mailto:' . esc_attr($user->user_email), $user->user_login));
$alt = !$alt;
if (!$last) {
$last = $registered;
}
}
echo '</table>';
echo '<table class="gmember-dashboard -table-summary"></tbody>';
echo '<tr><td>';
printf(_x('Last User Registered %s ago', 'Signup Admin Widget', GMEMBER_TEXTDOMAIN), human_time_diff($last));
echo '</td><td>';
if ($spam_users = $gMemberNetwork->get_spam_count()) {
printf(_nx('With %s Spam User', 'With %s Spam Users', $spam_users, 'Signup Admin Widget', GMEMBER_TEXTDOMAIN), number_format_i18n($spam_users));
} else {
_ex('With No Spam User', 'Signup Admin Widget', GMEMBER_TEXTDOMAIN);
}
echo '</td></tr><tr><td>';
$super_admins = count(get_super_admins());
printf(_nx('And %s Super Admin', 'And %s Super Admins', $super_admins, 'Signup Admin Widget', GMEMBER_TEXTDOMAIN), number_format_i18n($super_admins));
echo '</td><td>';
$user_count = get_user_count();
printf(_nx('Total of One User', 'Total of %s Users', $user_count, 'Signup Admin Widget', GMEMBER_TEXTDOMAIN), number_format_i18n($user_count));
echo '</td></tr>';
echo '</tbody></table>';
}
}
示例5: is_super_admin
function is_super_admin($user_id = false)
{
if (!$user_id) {
$current_user = wp_get_current_user();
$user_id = !empty($current_user) ? $current_user->id : 0;
}
if (!$user_id) {
return false;
}
$user = new WP_User($user_id);
if (is_multisite()) {
$super_admins = get_super_admins();
if (is_array($super_admins) && in_array($user->user_login, $super_admins)) {
return true;
}
} else {
if ($user->has_cap('delete_users')) {
return true;
}
}
return false;
}
示例6: code_snippets_upgrader
/**
* Preform upgrade tasks such as deleting and updating options
* @since 2.0
*/
function code_snippets_upgrader()
{
/* Get the current plugin version from the database */
$prev_version = get_option('code_snippets_version');
/* Check if this is the first plugin run */
if (!$prev_version) {
/* Register capabilities */
$role = get_role(apply_filters('code_snippets_role', 'administrator'));
$role->add_cap(apply_filters('code_snippets_cap', 'manage_snippets'));
}
/* Check if we have upgraded from an older version */
if (version_compare($prev_version, CODE_SNIPPETS_VERSION, '<')) {
/* Upgrade the database tables */
create_code_snippets_tables(true);
/* Update the plugin version stored in the database */
update_option('code_snippets_version', CODE_SNIPPETS_VERSION);
}
/* Run multisite-only upgrades */
if (is_multisite() && is_main_site()) {
/* Get the current plugin version from the database */
$prev_ms_version = get_site_option('code_snippets_version');
/* Check if this is the first plugin run */
if (!$prev_ms_version) {
/* Register multisite capabilities */
$network_cap = apply_filters('code_snippets_network_cap', 'manage_network_snippets');
$supers = get_super_admins();
foreach ($supers as $admin) {
$user = new WP_User(0, $admin);
$user->add_cap($network_cap);
}
}
/* Check if we have upgraded from an older version */
if (version_compare($prev_ms_version, CODE_SNIPPETS_VERSION, '<')) {
/* Update the plugin version stored in the database */
update_site_option('code_snippets_version', CODE_SNIPPETS_VERSION);
}
}
}
示例7: store_users
/**
* Store available users
*
* @since 1.5
* @since 1.6 Moved to this class from main class
* @access public
* @return void
*/
public function store_users()
{
// Is the current user a super admin?
$is_super_admin = is_super_admin($this->get_curUser()->ID);
// Is it also one of the manually configured superior admins?
$is_superior_admin = VAA_API::is_superior_admin($this->get_curUser()->ID);
if (is_network_admin()) {
// Get super admins (returns logins)
$users = get_super_admins();
// Remove current user
if (in_array($this->get_curUser()->user_login, $users)) {
unset($users[array_search($this->get_curUser()->user_login, $users)]);
}
// Convert logins to WP_User objects and filter them for superior admins
foreach ($users as $key => $user_login) {
$user = get_user_by('login', $user_login);
if ($user && !in_array($user->user_login, VAA_API::get_superior_admins())) {
$users[$key] = get_user_by('login', $user_login);
} else {
unset($users[$key]);
}
}
} else {
$user_args = array('orderby' => 'display_name', 'exclude' => array_merge(VAA_API::get_superior_admins(), array($this->get_curUser()->ID)));
// Do not get regular admins for normal installs (WP 4.4+)
if (!is_multisite() && !$is_superior_admin) {
$user_args['role__not_in'] = 'administrator';
}
// Sort users by role and filter them on available roles
$users = $this->filter_sort_users_by_role(get_users($user_args));
}
$userids = array();
$usernames = array();
// Loop though all users
foreach ($users as $user_key => $user) {
// If the current user is not a superior admin, run the user filters
if (true !== $is_superior_admin) {
/**
* Implement checks instead of is_super_admin() because it adds a lot unnecessary queries
*
* @since 1.5.2
* @See is_super_admin()
* @link https://developer.wordpress.org/reference/functions/is_super_admin/
*/
//if ( is_super_admin( $user->ID ) ) {
if (is_multisite() && in_array($user->user_login, (array) get_super_admins())) {
// Remove super admins for multisites
unset($users[$user_key]);
continue;
} elseif (!is_multisite() && $user->has_cap('administrator')) {
// Remove regular admins for normal installs
unset($users[$user_key]);
continue;
} elseif (!$is_super_admin && $user->has_cap('view_admin_as')) {
// Remove users who can access this plugin for non-admin users with the view_admin_as capability
unset($users[$user_key]);
continue;
}
}
// Add users who can't access this plugin to the users list
$userids[$user->data->ID] = $user->data->display_name;
$usernames[$user->data->user_login] = $user->data->display_name;
}
$this->set_users($users);
$this->set_userids($userids);
$this->set_usernames($usernames);
}
示例8: is_super_admin
/**
* Determine if user is a site admin.
*
* @since 3.0.0
*
* @param int $user_id (Optional) The ID of a user. Defaults to the current user.
* @return bool True if the user is a site admin.
*/
function is_super_admin( $user_id = false ) {
if ( $user_id )
$user = new WP_User( $user_id );
else
$user = wp_get_current_user();
if ( ! $user->exists() )
return false;
if ( is_multisite() ) {
$super_admins = get_super_admins();
if ( is_array( $super_admins ) && in_array( $user->user_login, $super_admins ) )
return true;
} else {
if ( $user->has_cap('delete_users') )
return true;
}
return false;
}
示例9: confirm_delete_users
/**
*
* @param array $users
*/
function confirm_delete_users($users)
{
$current_user = wp_get_current_user();
if (!is_array($users) || empty($users)) {
return false;
}
?>
<h1><?php
esc_html_e('Users');
?>
</h1>
<?php
if (1 == count($users)) {
?>
<p><?php
_e('You have chosen to delete the user from all networks and sites.');
?>
</p>
<?php
} else {
?>
<p><?php
_e('You have chosen to delete the following users from all networks and sites.');
?>
</p>
<?php
}
?>
<form action="users.php?action=dodelete" method="post">
<input type="hidden" name="dodelete" />
<?php
wp_nonce_field('ms-users-delete');
$site_admins = get_super_admins();
$admin_out = '<option value="' . esc_attr($current_user->ID) . '">' . $current_user->user_login . '</option>';
?>
<table class="form-table">
<?php
foreach ($allusers = (array) $_POST['allusers'] as $user_id) {
if ($user_id != '' && $user_id != '0') {
$delete_user = get_userdata($user_id);
if (!current_user_can('delete_user', $delete_user->ID)) {
wp_die(sprintf(__('Warning! User %s cannot be deleted.'), $delete_user->user_login));
}
if (in_array($delete_user->user_login, $site_admins)) {
wp_die(sprintf(__('Warning! User cannot be deleted. The user %s is a network administrator.'), '<em>' . $delete_user->user_login . '</em>'));
}
?>
<tr>
<th scope="row"><?php
echo $delete_user->user_login;
?>
<?php
echo '<input type="hidden" name="user[]" value="' . esc_attr($user_id) . '" />' . "\n";
?>
</th>
<?php
$blogs = get_blogs_of_user($user_id, true);
if (!empty($blogs)) {
?>
<td><fieldset><p><legend><?php
printf(__('What should be done with content owned by %s?'), '<em>' . $delete_user->user_login . '</em>');
?>
</legend></p>
<?php
foreach ((array) $blogs as $key => $details) {
$blog_users = get_users(array('blog_id' => $details->userblog_id, 'fields' => array('ID', 'user_login')));
if (is_array($blog_users) && !empty($blog_users)) {
$user_site = "<a href='" . esc_url(get_home_url($details->userblog_id)) . "'>{$details->blogname}</a>";
$user_dropdown = '<label for="reassign_user" class="screen-reader-text">' . __('Select a user') . '</label>';
$user_dropdown .= "<select name='blog[{$user_id}][{$key}]' id='reassign_user'>";
$user_list = '';
foreach ($blog_users as $user) {
if (!in_array($user->ID, $allusers)) {
$user_list .= "<option value='{$user->ID}'>{$user->user_login}</option>";
}
}
if ('' == $user_list) {
$user_list = $admin_out;
}
$user_dropdown .= $user_list;
$user_dropdown .= "</select>\n";
?>
<ul style="list-style:none;">
<li><?php
printf(__('Site: %s'), $user_site);
?>
</li>
<li><label><input type="radio" id="delete_option0" name="delete[<?php
echo $details->userblog_id . '][' . $delete_user->ID;
?>
]" value="delete" checked="checked" />
<?php
_e('Delete all content.');
?>
//.........这里部分代码省略.........
示例10: display_rows
function display_rows()
{
global $current_site, $mode;
$alt = '';
$super_admins = get_super_admins();
foreach ($this->items as $user) {
$alt = 'alternate' == $alt ? '' : 'alternate';
$status_list = array('spam' => 'site-spammed', 'deleted' => 'site-deleted');
foreach ($status_list as $status => $col) {
if ($user->{$status}) {
$alt .= " {$col}";
}
}
?>
<tr class="<?php
echo $alt;
?>
">
<?php
list($columns, $hidden) = $this->get_column_info();
foreach ($columns as $column_name => $column_display_name) {
$class = "class='{$column_name} column-{$column_name}'";
$style = '';
if (in_array($column_name, $hidden)) {
$style = ' style="display:none;"';
}
$attributes = "{$class}{$style}";
switch ($column_name) {
case 'cb':
?>
<th scope="row" class="check-column">
<input type="checkbox" id="blog_<?php
echo $user->ID;
?>
" name="allusers[]" value="<?php
echo esc_attr($user->ID);
?>
" />
</th>
<?php
break;
case 'username':
$avatar = get_avatar($user->user_email, 32);
if (get_current_user_id() == $user->ID) {
$edit_link = esc_url(network_admin_url('profile.php'));
} else {
$edit_link = esc_url(network_admin_url(add_query_arg('wp_http_referer', urlencode(stripslashes($_SERVER['REQUEST_URI'])), 'user-edit.php?user_id=' . $user->ID)));
}
echo "<td {$attributes}>";
?>
<?php
echo $avatar;
?>
<strong><a href="<?php
echo $edit_link;
?>
" class="edit"><?php
echo stripslashes($user->user_login);
?>
</a><?php
if (in_array($user->user_login, $super_admins)) {
echo ' - ' . __('Super Admin');
}
?>
</strong>
<br/>
<?php
$actions = array();
$actions['edit'] = '<a href="' . $edit_link . '">' . __('Edit') . '</a>';
if (current_user_can('delete_user', $user->ID) && !in_array($user->user_login, $super_admins)) {
$actions['delete'] = '<a href="' . ($delete = esc_url(network_admin_url(add_query_arg('_wp_http_referer', urlencode(stripslashes($_SERVER['REQUEST_URI'])), wp_nonce_url('edit.php', 'deleteuser') . '&action=deleteuser&id=' . $user->ID))) . '" class="delete">' . __('Delete') . '</a>');
}
$actions = apply_filters('ms_user_row_actions', $actions, $user);
echo $this->row_actions($actions);
?>
</td>
<?php
break;
case 'name':
echo "<td {$attributes}>{$user->first_name} {$user->last_name}</td>";
break;
case 'email':
echo "<td {$attributes}><a href='mailto:{$user->user_email}'>{$user->user_email}</a></td>";
break;
case 'registered':
if ('list' == $mode) {
$date = 'Y/m/d';
} else {
$date = 'Y/m/d \\<\\b\\r \\/\\> g:i:s a';
}
echo "<td {$attributes}>" . mysql2date($date, $user->user_registered) . "</td>";
break;
case 'blogs':
$blogs = get_blogs_of_user($user->ID, true);
echo "<td {$attributes}>";
if (is_array($blogs)) {
foreach ((array) $blogs as $key => $val) {
if (!can_edit_network($val->site_id)) {
continue;
}
//.........这里部分代码省略.........
示例11: handle_row_actions
/**
* Generates and displays row action links.
*
* @since 4.3.0
* @access protected
*
* @param object $user User being acted upon.
* @param string $column_name Current column name.
* @param string $primary Primary column name.
* @return string Row actions output for users in Multisite.
*/
protected function handle_row_actions($user, $column_name, $primary)
{
if ($primary !== $column_name) {
return '';
}
$super_admins = get_super_admins();
$edit_link = esc_url(add_query_arg('wp_http_referer', urlencode(wp_unslash($_SERVER['REQUEST_URI'])), get_edit_user_link($user->ID)));
$actions = array();
$actions['edit'] = '<a href="' . $edit_link . '">' . __('Edit') . '</a>';
if (current_user_can('delete_user', $user->ID) && !in_array($user->user_login, $super_admins)) {
$actions['delete'] = '<a href="' . ($delete = esc_url(network_admin_url(add_query_arg('_wp_http_referer', urlencode(wp_unslash($_SERVER['REQUEST_URI'])), wp_nonce_url('users.php', 'deleteuser') . '&action=deleteuser&id=' . $user->ID))) . '" class="delete">' . __('Delete') . '</a>');
}
/**
* Filter the action links displayed under each user in the Network Admin Users list table.
*
* @since 3.2.0
*
* @param array $actions An array of action links to be displayed.
* Default 'Edit', 'Delete'.
* @param WP_User $user WP_User object.
*/
$actions = apply_filters('ms_user_row_actions', $actions, $user);
return $this->row_actions($actions);
}
示例12: becomeAdmin
public static function becomeAdmin()
{
$db = new wfDB();
global $wpdb;
$adminUserID = false;
$userSource = '';
if (is_multisite()) {
$users = get_users('role=super&fields=ID');
if (sizeof($users) < 1) {
$supers = get_super_admins();
if (sizeof($supers) > 0) {
foreach ($supers as $superLogin) {
$superDat = get_user_by('login', $superLogin);
if ($superDat) {
$users = array($superDat->ID);
$userSource = 'multisite get_super_admins() function';
break;
}
}
}
} else {
$userSource = 'multisite get_users() function';
}
} else {
$users = get_users('role=administrator&fields=ID');
if (sizeof($users) < 1) {
$supers = get_super_admins();
if (sizeof($supers) > 0) {
foreach ($supers as $superLogin) {
$superDat = get_user_by('login', $superLogin);
if ($superDat) {
$users = array($superDat->ID);
$userSource = 'singlesite get_super_admins() function';
break;
}
}
}
} else {
$userSource = 'singlesite get_users() function';
}
}
if (sizeof($users) > 0) {
sort($users, SORT_NUMERIC);
$adminUserID = $users[0];
} else {
//Last ditch attempt
$adminUserID = $db->querySingle("select user_id from " . $wpdb->usermeta . " where meta_key='" . $wpdb->base_prefix . "user_level' order by meta_value desc, user_id asc limit 1");
if (!$adminUserID) {
//One final attempt for those who have changed their table prefixes but the meta_key is still wp_ prefixed...
$adminUserID = $db->querySingle("select user_id from " . $wpdb->usermeta . " where meta_key='wp_user_level' order by meta_value desc, user_id asc limit 1");
if (!$adminUserID) {
self::status(1, 'error', "Could not get the administrator's user ID. Scan can't continue.");
exit;
}
}
$userSource = 'manual DB query';
}
$adminUsername = $db->querySingle("select user_login from " . $wpdb->users . " where ID=%d", $adminUserID);
self::status(4, 'info', "Scan will run as admin user '{$adminUsername}' with ID '{$adminUserID}' sourced from: {$userSource}");
wp_set_current_user($adminUserID);
if (!is_user_logged_in()) {
self::status(1, 'error', "Scan could not sign in as user '{$adminUsername}' with ID '{$adminUserID}' from source '{$userSource}'. Scan can't continue.");
exit;
}
self::status(4, 'info', "Scan authentication complete.");
}
示例13: create
/**
* Create a site in a multisite install.
*
* ## OPTIONS
*
* --slug=<slug>
* : Path for the new site. Subdomain on subdomain installs, directory on subdirectory installs.
*
* [--title=<title>]
* : Title of the new site. Default: prettified slug.
*
* [--email=<email>]
* : Email for Admin user. User will be created if none exists. Assignement to Super Admin if not included.
*
* [--network_id=<network-id>]
* : Network to associate new site with. Defaults to current network (typically 1).
*
* [--private]
* : If set, the new site will be non-public (not indexed)
*
* [--porcelain]
* : If set, only the site id will be output on success.
*/
public function create($_, $assoc_args)
{
if (!is_multisite()) {
WP_CLI::error('This is not a multisite install.');
}
global $wpdb, $current_site;
$base = $assoc_args['slug'];
$title = \WP_CLI\Utils\get_flag_value($assoc_args, 'title', ucfirst($base));
$email = empty($assoc_args['email']) ? '' : $assoc_args['email'];
// Network
if (!empty($assoc_args['network_id'])) {
$network = $this->_get_network($assoc_args['network_id']);
if ($network === false) {
WP_CLI::error(sprintf('Network with id %d does not exist.', $assoc_args['network_id']));
}
} else {
$network = $current_site;
}
$public = !\WP_CLI\Utils\get_flag_value($assoc_args, 'private');
// Sanitize
if (preg_match('|^([a-zA-Z0-9-])+$|', $base)) {
$base = strtolower($base);
}
// If not a subdomain install, make sure the domain isn't a reserved word
if (!is_subdomain_install()) {
$subdirectory_reserved_names = apply_filters('subdirectory_reserved_names', array('page', 'comments', 'blog', 'files', 'feed'));
if (in_array($base, $subdirectory_reserved_names)) {
WP_CLI::error('The following words are reserved and cannot be used as blog names: ' . implode(', ', $subdirectory_reserved_names));
}
}
// Check for valid email, if not, use the first Super Admin found
// Probably a more efficient way to do this so we dont query for the
// User twice if super admin
$email = sanitize_email($email);
if (empty($email) || !is_email($email)) {
$super_admins = get_super_admins();
$email = '';
if (!empty($super_admins) && is_array($super_admins)) {
// Just get the first one
$super_login = $super_admins[0];
$super_user = get_user_by('login', $super_login);
if ($super_user) {
$email = $super_user->user_email;
}
}
}
if (is_subdomain_install()) {
$path = '/';
$url = $newdomain = $base . '.' . preg_replace('|^www\\.|', '', $network->domain);
} else {
$newdomain = $network->domain;
$path = '/' . trim($base, '/') . '/';
$url = $network->domain . $path;
}
$user_id = email_exists($email);
if (!$user_id) {
// Create a new user with a random password
$password = wp_generate_password(12, false);
$user_id = wpmu_create_user($base, $password, $email);
if (false == $user_id) {
WP_CLI::error("Can't create user.");
} else {
wp_new_user_notification($user_id, $password);
}
}
$wpdb->hide_errors();
$id = wpmu_create_blog($newdomain, $path, $title, $user_id, array('public' => $public), $network->id);
$wpdb->show_errors();
if (!is_wp_error($id)) {
if (!is_super_admin($user_id) && !get_user_option('primary_blog', $user_id)) {
update_user_option($user_id, 'primary_blog', $id, true);
}
// Prevent mailing admins of new sites
// @TODO argument to pass in?
// $content_mail = sprintf(__( "New site created by WP Command Line Interface\n\nAddress: %2s\nName: %3s"), get_site_url($id), stripslashes($title));
// wp_mail(get_site_option('admin_email'), sprintf(__('[%s] New Site Created'), $current_site->site_name), $content_mail, 'From: "Site Admin" <'.get_site_option( 'admin_email').'>');
} else {
//.........这里部分代码省略.........
示例14: confirm_delete_users
function confirm_delete_users($users)
{
$current_user = wp_get_current_user();
if (!is_array($users)) {
return false;
}
screen_icon();
?>
<h2><?php
esc_html_e('Users');
?>
</h2>
<p><?php
_e('Transfer or delete posts and links before deleting users.');
?>
</p>
<form action="users.php?action=dodelete" method="post">
<input type="hidden" name="dodelete" />
<?php
wp_nonce_field('ms-users-delete');
$site_admins = get_super_admins();
$admin_out = "<option value='{$current_user->ID}'>{$current_user->user_login}</option>";
foreach ($allusers = (array) $_POST['allusers'] as $key => $val) {
if ($val != '' && $val != '0') {
$delete_user = new WP_User($val);
if (!current_user_can('delete_user', $delete_user->ID)) {
wp_die(sprintf(__('Warning! User %s cannot be deleted.'), $delete_user->user_login));
}
if (in_array($delete_user->user_login, $site_admins)) {
wp_die(sprintf(__('Warning! User cannot be deleted. The user %s is a network admnistrator.'), $delete_user->user_login));
}
echo "<input type='hidden' name='user[]' value='{$val}'/>\n";
$blogs = get_blogs_of_user($val, true);
if (!empty($blogs)) {
?>
<br /><fieldset><p><legend><?php
printf(__("What should be done with posts and links owned by <em>%s</em>?"), $delete_user->user_login);
?>
</legend></p>
<?php
foreach ((array) $blogs as $key => $details) {
$blog_users = get_users(array('blog_id' => $details->userblog_id));
if (is_array($blog_users) && !empty($blog_users)) {
$user_site = "<a href='" . esc_url(get_home_url($details->userblog_id)) . "'>{$details->blogname}</a>";
$user_dropdown = "<select name='blog[{$val}][{$key}]'>";
$user_list = '';
foreach ($blog_users as $user) {
if (!in_array($user->ID, $allusers)) {
$user_list .= "<option value='{$user->ID}'>{$user->user_login}</option>";
}
}
if ('' == $user_list) {
$user_list = $admin_out;
}
$user_dropdown .= $user_list;
$user_dropdown .= "</select>\n";
?>
<ul style="list-style:none;">
<li><?php
printf(__('Site: %s'), $user_site);
?>
</li>
<li><label><input type="radio" id="delete_option0" name="delete[<?php
echo $details->userblog_id . '][' . $delete_user->ID;
?>
]" value="delete" checked="checked" />
<?php
_e('Delete all posts and links.');
?>
</label></li>
<li><label><input type="radio" id="delete_option1" name="delete[<?php
echo $details->userblog_id . '][' . $delete_user->ID;
?>
]" value="reassign" />
<?php
echo __('Attribute all posts and links to:') . '</label>' . $user_dropdown;
?>
</li>
</ul>
<?php
}
}
echo "</fieldset>";
}
}
}
submit_button(__('Confirm Deletion'), 'delete');
?>
</form>
<?php
return true;
}
示例15: user_admin_status_metabox
/**
* Render the Status metabox for user's profile screen.
*
* Actions are:
* - Update profile fields if xProfile component is active
* - Spam/Unspam user
*
* @since 2.0.0
*
* @param WP_User|null $user The WP_User object to be edited.
*/
public function user_admin_status_metabox($user = null)
{
// Bail if no user id or if the user has not activated their account yet.
if (empty($user->ID)) {
return;
}
// Bail if user has not been activated yet (how did you get here?).
if (isset($user->user_status) && 2 == $user->user_status) {
?>
<p class="not-activated"><?php
esc_html_e('User account has not yet been activated', 'buddypress');
?>
</p><br/>
<?php
return;
}
?>
<div class="submitbox" id="submitcomment">
<div id="minor-publishing">
<div id="misc-publishing-actions">
<?php
// Get the spam status once here to compare against below.
$is_spammer = bp_is_user_spammer($user->ID);
/**
* In configs where BuddyPress is not network activated,
* regular admins cannot mark a user as a spammer on front
* end. This prevent them to do it in backend.
*
* Also prevent admins from marking themselves or other
* admins as spammers.
*/
if (empty($this->is_self_profile) && !in_array($user->user_login, get_super_admins()) && empty($this->subsite_activated) || !empty($this->subsite_activated) && current_user_can('manage_network_users')) {
?>
<div class="misc-pub-section" id="comment-status-radio">
<label class="approved"><input type="radio" name="user_status" value="ham" <?php
checked($is_spammer, false);
?>
><?php
esc_html_e('Active', 'buddypress');
?>
</label><br />
<label class="spam"><input type="radio" name="user_status" value="spam" <?php
checked($is_spammer, true);
?>
><?php
esc_html_e('Spammer', 'buddypress');
?>
</label>
</div>
<?php
}
?>
<div class="misc-pub-section curtime misc-pub-section-last">
<?php
// Translators: Publish box date format, see http://php.net/date.
$datef = __('M j, Y @ G:i', 'buddypress');
$date = date_i18n($datef, strtotime($user->user_registered));
?>
<span id="timestamp"><?php
printf(__('Registered on: %s', 'buddypress'), '<strong>' . $date . '</strong>');
?>
</span>
</div>
</div> <!-- #misc-publishing-actions -->
<div class="clear"></div>
</div><!-- #minor-publishing -->
<div id="major-publishing-actions">
<div id="publishing-action">
<a class="button bp-view-profile" href="<?php
echo esc_url(bp_core_get_user_domain($user->ID));
?>
" target="_blank"><?php
esc_html_e('View Profile', 'buddypress');
?>
</a>
<?php
submit_button(esc_html__('Update Profile', 'buddypress'), 'primary', 'save', false);
?>
</div>
<div class="clear"></div>
//.........这里部分代码省略.........