/** * profile_screen_new_request() * * Action to notify site_admin that a new request has been sent */ function profile_screen_new_request($field_id, $field_value) { //required to search for superadmins require_once ABSPATH . 'wp-admin/includes/user.php'; global $bp; if ($field_value == __('Apply for Teacher', 'bpsp')) { $users_search = new WP_User_Search(null, null, 'administrator'); $superadmins = $users_search->get_results(); $content = $this->request_message($bp->loggedin_user->userdata, true); $subject = $this->request_message($bp->loggedin_user->userdata, false, true); if (!is_super_admin()) { messages_new_message(array('recipients' => $superadmins, 'subject' => $subject, 'content' => $content)); } } if ($field_value == __('Teacher', 'bpsp') && !is_super_admin()) { wp_die(__('BuddyPress Courseware error, you are not allowed to assign Teachers.')); } // Add an action every time a new teacher is added if ($field_value == __('Teacher', 'bpsp') && is_super_admin()) { do_action('courseware_new_teacher_added', $bp->displayed_user->id); } // Add an action every time a teacher is removed if ($field_value != __('Teacher', 'bpsp')) { do_action('courseware_new_teacher_removed', $bp->displayed_user->id); } }
/** * @see IdentityProvider_Driver::admin_user. */ public function admin_user() { $wp_user_search = new WP_User_Search(null, null, self::$_params['groups'][count(self::$_params['groups']) - 1]); $admins = $wp_user_search->get_results(); if (count($admins) == 0) { throw new Exception("@todo NO ADMIN USER FOUND"); } return new Wordpress_User($admins[0]); }
function adopt_all_orphans() { // Query the users $wp_user_search = new WP_User_Search(); foreach ($wp_user_search->get_results() as $userid) { $user = new WP_User($userid); if (!$user->has_cap('read')) { $user->set_role(get_option('wporphanage_role')); } } }
/** * If the stats package was previously unused, this means that prior users stats were * not tracked. So, we're going to create some default stats based on the user registration * date and user role. * * @since 0.2 */ function members_component_stats_create_initial_stats() { global $wp_roles; $stats = array(); foreach ($wp_roles->role_objects as $key => $role) { $sta = array(); $search = new WP_User_Search('', '', $role->name); $users = $search->get_results(); if (isset($users) && is_array($users)) { foreach ($users as $user) { $new_user = new WP_User($user); $sta[$new_user->ID] = array('id' => $new_user->ID, 'role' => $role->name, 'date' => $new_user->user_registered, 'year' => mysql2date('Y', $new_user->user_registered), 'month' => mysql2date('m', $new_user->user_registered), 'day' => mysql2date('d', $new_user->user_registered)); } } $stats[$role->name] = $sta; } add_option('members_statistics', $stats); }
/** * Count the posts * * @param $author_id * @param $post_type * @return array */ function get_users_by_role($search_term = '', $page = '', $role = "Author") { require_once ABSPATH . "/wp-admin/includes/user.php"; $wp_user_search = new WP_User_Search($search_term, $page, $role); return $wp_user_search->get_results(); }
function getUsersByRole($role) { // find all users with given role // via http://sltaylor.co.uk/blog/get-wordpress-users-by-role/ if (class_exists('WP_User_Search')) { $wp_user_search = new WP_User_Search('', '', $role); $userIDs = $wp_user_search->get_results(); } else { global $wpdb; $userIDs = $wpdb->get_col(' SELECT ID FROM ' . $wpdb->users . ' INNER JOIN ' . $wpdb->usermeta . ' ON ' . $wpdb->users . '.ID = ' . $wpdb->usermeta . '.user_id WHERE ' . $wpdb->usermeta . '.meta_key = \'' . $wpdb->prefix . 'capabilities\' AND ' . $wpdb->usermeta . '.meta_value LIKE \'%"' . $role . '"%\' '); } return $userIDs; }
function admin_delete($id, $obj) { global $wp_roles; $id = $obj->id; if (!isset($obj->data[$id])) { return $obj->error(__('Role not found, it cannot be deleted.', 'pods')); } $default_role = get_option('default_role'); if ($id == $default_role) { return $obj->error(sprintf(__('You cannot remove the <strong>%s</strong> role, you must set a new default role for the site first.', 'pods'), $obj->data[$id]['name'])); } $wp_user_search = new WP_User_Search('', '', $id); $users = $wp_user_search->get_results(); if (!empty($users) && is_array($users)) { foreach ($users as $user) { $user_object = new WP_User($user); if ($user_object->has_cap($id)) { $user_object->remove_role($id); $user_object->set_role($default_role); } } } remove_role($id); $roles = array(); foreach ($wp_roles->role_objects as $key => $role) { $count = $this->count_users($key); $roles[$key] = array('id' => $key, 'label' => $wp_roles->role_names[$key], 'name' => $key, 'capabilities' => count((array) $role->capabilities), 'users' => sprintf(_n('%s User', '%s Users', $count, 'pods'), $count)); if ($default_role == $key) { $roles[$key]['label'] .= ' (site default)'; } if (0 < $count && pods_is_admin(array('list_users'))) { $roles[$key]['users'] .= '<br /><a href="' . admin_url(esc_url('users.php?role=' . $key)) . '">' . __('View Users', 'pods') . '</a>'; } } $name = $obj->data[$id]['label'] . ' (' . $obj->data[$id]['name'] . ')'; $obj->data = $roles; $obj->total = count($roles); $obj->total_found = count($roles); $obj->message('<strong>' . $name . '</strong> ' . __('role removed from site.', 'pods')); }
function WP_members_list_list() { global $wp_roles, $getWP, $tern_wp_msg, $tern_wp_members_defaults, $current_user, $notice; get_currentuserinfo(); $o = $getWP->getOption('tern_wp_members', $tern_wp_members_defaults); $wps = new WP_User_Search($_GET['query'], $_GET['userspage'], $_GET['role']); $paging_text = paginate_links(array('total' => ceil($wps->total_users_for_query / $wps->users_per_page), 'current' => $wps->page, 'base' => 'admin.php?page=members-list-edit-members-list&%_%', 'format' => 'userspage=%#%', 'add_args' => $args)); if ($paging_text) { $paging_text = sprintf('<span class="displaying-num">' . __('Displaying %s–%s of %s') . '</span>%s', number_format_i18n(($wps->page - 1) * $wps->users_per_page + 1), number_format_i18n(min($wps->page * $wps->users_per_page, $wps->total_users_for_query)), number_format_i18n($wps->total_users_for_query), $paging_text); } ?> <div class="wrap"> <div id="icon-users" class="icon32"><br /></div> <h2>Members List</h2> <?php if (!empty($notice)) { ?> <div id="notice" class="error"><p><?php echo $notice; ?> </p></div><?php } ?> <p>Here you are able to select which of your members you'd like to show or hide in your members list. By default all members are showm.</p> <?php if (!empty($tern_wp_msg)) { echo '<div id="message" class="updated fade"><p>' . $tern_wp_msg . '</p></div>'; } ?> <div class="filter"> <form id="list-filter" action="" method="get"> <ul class="subsubsub"> <?php $l = array(); $a = array(); $u = get_users_of_blog(); $t = count($u); foreach ((array) $u as $c) { $d = unserialize($c->meta_value); foreach ((array) $d as $e => $v) { if (!isset($a[$e])) { $a[$e] = 0; } $a[$e]++; } } unset($u); $current_role = false; $class = empty($role) ? ' class="current"' : ''; $l[] = "<li><a href='admin.php?page=members-list-edit-members-list'{$class}>" . sprintf(__ngettext('All<span class="count">(%s)</span>', 'All <span class="count">(%s)</span>', $t), number_format_i18n($t)) . '</a>'; foreach ($wp_roles->get_names() as $s => $name) { if (!isset($a[$s])) { continue; } $class = ''; if ($s == $role) { $current_role = $role; $class = ' class="current"'; } $name = translate_with_context($name); $name = sprintf(_c('%1$s <span class="count">(%2$s)</span>|user role with count'), $name, $a[$s]); $l[] = "<li><a href='admin.php?page=members-list-edit-members-list&role={$s}'{$class}>{$name}</a>"; } echo implode(" |</li>\n", $l) . '</li>'; unset($l); ?> </ul> </form> </div> <form class="search-form" action="" method="get"> <p class="search-box"> <label class="hidden" for="user-search-input">Search Users:</label> <input type="text" class="search-input" id="user-search-input" name="query" value="" /> <input type="hidden" id="page" name="page" value="<?php echo $_REQUEST['page']; ?> " /> <input type="submit" value="Search Users" class="button" /> </p> </form> <form id="posts-filter" action="" method="get"> <div class="tablenav"> <?php if ($wps->results_are_paged()) { ?> <div class="tablenav-pages"><?php echo $paging_text; ?> </div> <?php } ?> <div class="alignleft actions"> <select name="action"> <option value="" selected="selected">Bulk Actions</option> <option value="show">Show</option> <option value="hide">Hide</option> </select> <input type="submit" value="Apply" name="doaction" id="doaction" class="button-secondary action" /> </div> <br class="clear" /> </div> <table class="widefat fixed" cellspacing="0"> <thead> <tr class="thead"> <th scope="col" id="cb" class="manage-column column-cb check-column" style=""><input type="checkbox" /></th> <th scope="col" id="username" class="manage-column column-username" style="">Username</th> <th scope="col" id="name" class="manage-column column-name" style="">Name</th> <th scope="col" id="email" class="manage-column column-email" style="">E-mail</th> <th scope="col" id="role" class="manage-column column-role" style="">Role</th> <th scope="col" id="displayed" class="manage-column column-displayed" style="">Displayed</th> </tr> </thead> <tfoot> <tr class="thead"> <th scope="col" class="manage-column column-cb check-column" style=""><input type="checkbox" /></th> <th scope="col" class="manage-column column-username" style="">Username</th> <th scope="col" class="manage-column column-name" style="">Name</th> <th scope="col" class="manage-column column-email" style="">E-mail</th> <th scope="col" class="manage-column column-role" style="">Role</th> <th scope="col" id="displayed" class="manage-column column-displayed" style="">Displayed</th> </tr> </tfoot> <tbody id="users" class="list:user user-list"> <?php // $c = 0; //foreach($m as $u) { foreach ($wps->get_results() as $u) { $u = new WP_User($u); $r = $u->roles; $r = array_shift($r); if (!empty($_REQUEST['role']) and $_REQUEST['role'] != $r) { continue; } $d = is_float($c / 2) ? '' : ' class="alternate"'; $nu = $current_user; $e = $u->ID == $nu->ID ? 'profile.php' : 'user-edit.php?user_id=' . $u->ID . '&wp_http_referer=' . wp_get_referer(); ?> <tr id='user-<?php echo $u->ID; ?> '<?php echo $d; ?> > <th scope='row' class='check-column'><input type='checkbox' name='users[]' id='user_<?php echo $u->ID; ?> ' class='administrator' value='<?php echo $u->ID; ?> ' /></th> <td class="username column-username"> <?php echo get_avatar($u->ID, 32); ?> <strong> <a href="<?php echo $e; ?> "><?php echo $u->user_nicename; ?> </a> </strong><br /> <div class="row-actions"> <span class='edit'><a href="admin.php?page=members-list-edit-members-list&users%5B%5D=<?php echo $u->ID; ?> &action=show&_wpnonce=<?php echo wp_create_nonce('tern_wp_members_nonce'); ?> ">Show</a> | </span> <span class='edit'><a href="admin.php?page=members-list-edit-members-list&users%5B%5D=<?php echo $u->ID; ?> &action=hide&_wpnonce=<?php echo wp_create_nonce('tern_wp_members_nonce'); ?> ">Hide</a></span> </div> </td> <td class="name column-name"><?php echo $u->first_name . ' ' . $u->last_name; ?> </td> <td class="email column-email"><a href='mailto:<?php echo $u->user_email; ?> ' title='e-mail: <?php echo $u->user_email; ?> '><?php echo $u->user_email; ?> </a></td> <td class="role column-role"><?php echo $r; ?> </td> <td class="role column-displayed"><?php if (!empty($o['hidden']) and in_array($u->ID, $o['hidden'])) { echo 'no'; } else { echo 'yes'; } ?> </td> </tr> <?php $c++; } ?> </tbody> </table> <div class="tablenav"> <div class="alignleft actions"> <select name="action2"> <option value="" selected="selected">Bulk Actions</option> <option value="show">Show</option> <option value="hide">Hide</option> </select> <input type="hidden" id="page" name="page" value="members-list-edit-members-list" /> <input type="hidden" id="_wpnonce" name="_wpnonce" value="<?php echo wp_create_nonce('tern_wp_members_nonce'); ?> " /> <input type="submit" value="Apply" name="doaction2" id="doaction2" class="button-secondary action" /> </div> <br class="clear" /> </div> </form> </div> <?php }
?> </div> </form> <?php break; default: if (!empty($_GET['_wp_http_referer'])) { wp_redirect(remove_query_arg(array('_wp_http_referer', '_wpnonce'), stripslashes($_SERVER['REQUEST_URI']))); exit; } include './admin-header.php'; $usersearch = isset($_GET['usersearch']) ? $_GET['usersearch'] : null; $userspage = isset($_GET['userspage']) ? $_GET['userspage'] : null; $role = isset($_GET['role']) ? $_GET['role'] : null; // Query the user IDs for this page $wp_user_search = new WP_User_Search($usersearch, $userspage, $role); // Query the post counts for this page $post_counts = count_many_users_posts($wp_user_search->get_results()); // Query the users for this page cache_users($wp_user_search->get_results()); $messages = array(); if (isset($_GET['update'])) { switch ($_GET['update']) { case 'del': case 'del_many': $delete_count = isset($_GET['delete_count']) ? (int) $_GET['delete_count'] : 0; $messages[] = '<div id="message" class="updated"><p>' . sprintf(_n('%s user deleted', '%s users deleted', $delete_count), $delete_count) . '</p></div>'; break; case 'add': $messages[] = '<div id="message" class="updated"><p>' . __('New user created.') . '</p></div>'; break;
/** * Finds all users with specified role. * * @param string $role role to find * @return array found users */ function get_users_with_role($role) { $wp_user_search = new WP_User_Search("", "", $role); return $wp_user_search->get_results(); }
} default: if ( !empty($_GET['_wp_http_referer']) ) { wp_redirect(remove_query_arg(array('_wp_http_referer', '_wpnonce'), stripslashes($_SERVER['REQUEST_URI']))); exit; } wp_enqueue_script('admin-users'); wp_enqueue_script('admin-forms'); include('admin-header.php'); // Query the users $wp_user_search = new WP_User_Search($_GET['usersearch'], $_GET['userspage'], $_GET['role']); if ( isset($_GET['update']) ) : switch($_GET['update']) { case 'del': case 'del_many': ?> <?php $delete_count = (int) $_GET['delete_count']; ?> <div id="message" class="updated fade"><p><?php printf(__ngettext('%s user deleted', '%s users deleted', $delete_count), $delete_count); ?></p></div> <?php break; case 'add': ?> <div id="message" class="updated fade"><p><?php _e('New user created.'); ?></p></div> <?php break;
function bum_get_user_by_role($role) { if (class_exists('WP_User_Search')) { $wp_user_search = new WP_User_Search('', '', $role); $ids = $wp_user_search->get_results(); } else { global $wpdb; $ids = $wpdb->get_col('SELECT ID FROM ' . $wpdb->users . ' INNER JOIN ' . $wpdb->usermeta . ' ON ' . $wpdb->users . '.ID = ' . $wpdb->usermeta . '.user_id WHERE ' . $wpdb->usermeta . '.meta_key = \'' . $wpdb->prefix . 'capabilities\' AND ' . $wpdb->usermeta . '.meta_value LIKE \'%"' . $role . '"%\''); } return $ids; }
/** * Uninstalls the plugin * * @package webcomic * @since 3 */ public function uninstall() { global $wpdb; $this->domain(); $cat = (int) get_option('default_category'); if ($collections = get_terms('webcomic_collection', 'get=all&fields=ids')) { foreach ($collections as $collection) { wp_delete_term($collection, 'webcomic_collection'); } } if ($storylines = get_terms('webcomic_storyline', 'get=all&fields=ids')) { foreach ($storylines as $storyline) { wp_delete_term($storyline, 'webcomic_storyline'); } } if ($characters = get_terms('webcomic_character', 'get=all&fields=ids')) { foreach ($characters as $character) { wp_delete_term($character, 'webcomic_character'); } } $posts = $wpdb->get_col("SELECT ID FROM {$wpdb->posts} WHERE post_type = 'webcomic_post'"); $wpdb->query("UPDATE {$wpdb->posts} SET post_type = 'post' WHERE post_type = 'webcomic_post'"); $wpdb->query("DELETE FROM {$wpdb->postmeta} WHERE meta_key IN ( 'webcomic' )"); foreach ($posts as $p) { wp_set_object_terms($p, $cat, 'category'); } $wp_user_search = new WP_User_Search(null, null, null); foreach ($wp_user_search->get_results() as $userid) { delete_user_meta($userid, 'webcomic'); } $this->option(array('version' => $this->version, 'uninstall' => true)); $this->update['uninstalled'] = __('Information, files, and settings related to Webcomic have been removed.', 'webcomic'); }
function cleverness_todo_get_users($role) { $wp_user_search = new WP_User_Search('', '', $role); return $wp_user_search->get_results(); }
default: if ( !empty($_GET['_wp_http_referer']) ) { wp_redirect(remove_query_arg(array('_wp_http_referer', '_wpnonce'), stripslashes($_SERVER['REQUEST_URI']))); exit; } include('./admin-header.php'); $usersearch = isset($_GET['usersearch']) ? $_GET['usersearch'] : null; $userspage = isset($_GET['userspage']) ? $_GET['userspage'] : null; $role = isset($_GET['role']) ? $_GET['role'] : null; // Query the user IDs for this page $wp_user_search = new WP_User_Search($usersearch, $userspage, $role); // Query the post counts for this page $post_counts = count_many_users_posts($wp_user_search->get_results()); // Query the users for this page cache_users($wp_user_search->get_results()); $messages = array(); if ( isset($_GET['update']) ) : switch($_GET['update']) { case 'del': case 'del_many': $delete_count = isset($_GET['delete_count']) ? (int) $_GET['delete_count'] : 0; $messages[] = '<div id="message" class="updated"><p>' . sprintf(_n('%s user deleted', '%s users deleted', $delete_count), $delete_count) . '</p></div>'; break;
/** * get_admins() * * A wrapper for WordPress 3.1 `get_users()` with backcompat * @return Mixed, an array of objects */ function get_admins() { $admins = array(); if (function_exists('get_users')) { $superadmins = get_users(array('role' => 'administrator')); if ($superadmins) { foreach ($superadmins as $su) { $admins[] = $su->ID; } } } else { //required to search for superadmins require_once ABSPATH . 'wp-admin/includes/user.php'; $users_search = new WP_User_Search(null, null, 'administrator'); $admins = $users_search->get_results(); } return $admins; }
function manage_avatar_cache() { global $wpdb; $msg = ''; // Show commenter avatars too? $all = @$_GET['act'] == 'all'; // Check table updates... if (isset($_GET['user_id'])) { $msg = __('User Photo', 'avatars') . ' ' . (empty($_GET['avatar']) ? __('removed', 'avatars') : __('updated', 'avatars')) . '.'; update_user_meta($_GET['user_id'], 'avatar', $_GET['avatar']); update_user_meta($_GET['user_id'], 'twitter_id', $_GET['twitter_id']); } // Check form submission and update options... if (isset($_POST['submit'])) { $options_update = array('size' => $_POST['size'], 'scale' => $_POST['scale'], 'resize' => $_POST['resize'], 'upsize' => $_POST['upsize'], 'snapshots' => $_POST['snapshots'], 'in_posts' => $_POST['in_posts'], 'credit' => $_POST['credit'], 'twitter' => $_POST['twitter'], 'default' => $_POST['default'], 'upload_dir' => $_POST['upload_dir'], 'url_wrap' => $_POST['url_wrap'], 'name' => $_POST['name'], 'location' => $_POST['location'], 'legacy' => $_POST['legacy'], 'widget_enabled' => $_POST['widget_enabled'], 'upload_allowed' => $_POST['upload_allowed']); if ($this->networked) { update_site_option('plugin_avatars', $options_update); } else { update_option('plugin_avatars', $options_update); update_option('show_avatars', $_POST['show_avatars'] == 'on' ? 1 : 0); update_option('avatar_rating', $_POST['avatar_rating']); update_option('avatar_default', $_POST['wavatar']); } $msg = __('Options saved', 'avatars'); } // Get options and set form action var if ($this->networked) { $this->avatar_options = get_site_option('plugin_avatars'); $form_action = $_SERVER['PHP_SELF'] . '?page=add_local_avatar&updated=true'; } else { $this->avatar_options = get_option('plugin_avatars'); $wavatar = get_option('avatar_default'); $form_action = $_SERVER['PHP_SELF'] . '?page=' . basename(__FILE__) . '&updated=true'; } // Output any action message (note, can only be from a POST or GET not both). if (!empty($msg)) { echo "<div id='message' class='updated fade'><p>", $msg, "</p></div>"; } ?> <script language="Javascript"> function set_input_values(num) { var h = document.getElementById('href-' + num); h.href = h.href + '&avatar=' + document.getElementById('avatar-' + num).value; h.href = h.href + '&twitter_id=' + document.getElementById('twitter_id-' + num).value; } </script> <div class="wrap"> <span id='icon-users' class='icon32'></span><h2><?php _e('User Photo Settings', 'avatars'); ?> </h2> <h3><?php _e('User Photos', 'avatars'); ?> </h3> <?php // Do not show the table of this site's users/commentors if Avatars are disabled, instead place a hyperlink for them to enable it. if (!get_option('show_avatars')) { _e('Photos / Avatars have been disabled for this site. Enable avatars under <a href="/wp-admin/options-discussion.php">Settings > Discussion</a>', "avatars"); } else { $user_search = new WP_User_Search('', $_GET['userspage'], ''); // Do we have to page the results? if ($user_search->total_users_for_query > $user_search->users_per_page) { if ($this->networked) { $paging_base = basename($this->requestURI) . '&%_%'; } else { $paging_base = 'users.php?page=profiles.php&%_%'; } $user_search->paging_text = paginate_links(array('total' => ceil($user_search->total_users_for_query / $user_search->users_per_page), 'current' => $user_search->page, 'base' => $paging_base, 'format' => 'userspage=%#%')); } // How many per page (for commenters, if shown)? $per_page = $user_search->users_per_page; if ($user_search->results_are_paged()) { ?> <div class="tablenav"> <div class="tablenav-pages"><?php $user_search->page_links(); ?> </div> </div> <?php } ?> <table class='widefat'> <thead> <tr> <th><?php _e('Username', 'avatars'); ?> </th> <th><?php _e('Name (Nickname)', 'avatars'); ?> </th> <th><?php _e('e-Mail', 'avatars'); ?> </th> <th><?php _e('Twitter ID', 'avatars'); ?> </th> <th><?php _e('Local', 'avatars'); ?> </th> <th style="text-align: center;"><?php _e('Photo', 'avatars'); ?> </th> <th><?php _e('Type', 'avatars'); ?> </th> <th><?php _e('Action', 'avatars'); ?> </th> </tr> </thead> <tbody> <?php $i = 0; foreach ($user_search->get_results() as $id) { $user = new WP_User($id); printf('<tr%s>', $i % 2 == 0 ? " class='alternate'" : ""); printf('<td><a href="user-edit.php?user_id=%s">%s</a></td>', $id, $user->user_login); printf('<td>%s %s%s</td>', $user->first_name, $user->last_name, empty($user->nickname) ? '' : ' (' . $user->nickname . ')'); printf('<td><a href="mailto:%1$s">%1$s</a></td>', $user->user_email); printf('<td><input type="text" value="%s" id="twitter_id-%d" /></td>', $user->twitter_id, $i); printf('<td><input type="text" value="%s" size="35" id="avatar-%d" /></td>', $user->avatar, $i); printf('<td style="text-align: center;">%s</td>', get_avatar($id)); printf('<td>%s</td>', $this->get_avatar_type()); printf('<td><a href="%1$s&user_id=%2$s" class="edit" onclick="set_input_values(%3$d);" id="href-%3$d">%4$s</a></td>', $this->requestURI, $id, $i, __('Update', 'avatars')); echo "</tr>\n"; $i++; } ?> </tbody> </table> <?php if ($user_search->results_are_paged()) { ?> <div class="tablenav"> <div class="tablenav-pages"><?php $user_search->page_links(); ?> </div> </div> <?php } ?> <p><?php if (!$all) { echo __("Not showing photos for commenters.", 'avatars'), " <a href='" . $this->requestURI . "&act=all'>", __('Click here', 'avatars'), '</a> ', __("to show commenter avatars.", 'avatars'); } else { echo __("Showing avatars for commenters.", 'avatars'), " <a href='" . $this->requestURI . "'>", __('Click here', 'avatars'), '</a> ', __("to hide commenter photos.", 'avatars'); } ?> </p> <?php $com_page = isset($_GET['comspage']) ? $_GET['comspage'] : 1; if ($all) { $total = $wpdb->get_var("select count(distinct comment_author_email) from {$wpdb->comments} where comment_author_email != ''"); $limit_start = ($com_page - 1) * $per_page; $coms = $wpdb->get_results("select comment_author_email EML, comment_author ATH, count(comment_content) CNT from {$wpdb->comments} where comment_author_email != '' group by comment_author_email order by CNT DESC limit {$limit_start}, {$per_page}"); if ($total > $per_page) { $paging_text = paginate_links(array('total' => ceil($total / $per_page), 'current' => $com_page, 'base' => 'users.php?page=profiles.php&act=all&%_%', 'format' => 'comspage=%#%')); } if ($coms) { ?> <h3><?php _e('Commenter Photos', 'avatars'); ?> </h3> <?php if ($paging_text) { ?> <div class="tablenav"> <div class="tablenav-pages"><?php echo $paging_text; ?> </div> </div> <?php } ?> <table class='widefat'> <thead> <tr><th><?php _e('Name', 'avatars'); ?> </th><th><?php _e('e-Mail', 'avatars'); ?> </th><th style="text-align: center;"><?php _e('Comments', 'avatars'); ?> </th><th style="text-align: center;"><?php _e('Photo', 'avatars'); ?> </th></tr> </thead> <tbody> <?php $i = 0; foreach ($coms as $com) { if (!empty($com->EML)) { printf('<tr%s>', $i % 2 == 0 ? " class='alternate'" : ""); printf('<td>%s</td>', $com->ATH); printf('<td><a href="mailto:%1$s">%1$s</a></td>', $com->EML); printf('<td class="num">%s</td>', $com->CNT); printf('<td style="text-align: center;">%s</td>', get_avatar($com->EML)); echo "</tr>\n"; $i++; } } ?> </tbody> </table> <?php if ($paging_text) { ?> <div class="tablenav"> <div class="tablenav-pages"><?php echo $paging_text; ?> </div> </div> <?php } } } ?> <?php } // end if ?> <h3><?php _e('Photo Options', 'avatars'); ?> </h3> <form method="post" action="<?php echo $form_action; ?> "> <table class='form-table'> <?php // Do not repeat Settings > Discussion options in networked mode. if (!$this->networked) { ?> <tr> <td><label for="show_avatars"><?php _e('Show avatars:', 'avatars'); ?> </label><br /><small><?php _e('Repeated from <i>Settings » Discussion</i>', 'avatars'); ?> </small></td> <td><input type="checkbox" name="show_avatars" <?php echo get_option('show_avatars') ? 'checked' : ''; ?> /></td> <td><small><?php _e('Enable Photos.', 'avatars'); ?> </small></td> </tr> <tr> <td><?php _e('Photo rating:', 'avatars'); ?> <br /><small><?php _e('Repeated from <i>Settings » Discussion</i>', 'avatars'); ?> </small></td> <td> <input type='radio' name='avatar_rating' value='G' <?php echo get_option('avatar_rating') == 'G' ? 'checked="checked"' : ''; ?> /> G <br /> <input type='radio' name='avatar_rating' value='PG' <?php echo get_option('avatar_rating') == 'PG' ? 'checked="checked"' : ''; ?> /> PG<br /> <input type='radio' name='avatar_rating' value='R' <?php echo get_option('avatar_rating') == 'R' ? 'checked="checked"' : ''; ?> /> R <br /> <input type='radio' name='avatar_rating' value='X' <?php echo get_option('avatar_rating') == 'X' ? 'checked="checked"' : ''; ?> /> X </td> <td> <small>- <?php _e('Suitable for all audiences', 'avatars'); ?> </small><br /> <small>- <?php _e('Possibly offensive, usually for audiences 13 and above', 'avatars'); ?> </small><br /> <small>- <?php _e('Intended for adult audiences above 17', 'avatars'); ?> </small><br /> <small>- <?php _e('Even more mature than above', 'avatars'); ?> </small> </td> </tr> <?php } ?> <tr> <td><label for="idAvatarSize"><?php _e('Size:', 'avatars'); ?> </label></td> <td style="width: 70px;"><select id="idAvatarSize" name='size'><?php for ($i = 10; $i <= 100; $i = $i + 10) { echo "<option value='{$i}'"; if ($i == $this->avatar_options['size']) { echo " selected"; } echo ">{$i}</option>"; } ?> </select></td> <td><label for="idAvatarSize">px</label></td> </tr> <?php if (class_exists('SimpleXMLElement')) { ?> <tr> <td><label for="idTwitter"><?php _e('Twitter Photo:', 'avatars'); ?> </label></td> <td><input type="checkbox" id="idTwitter" name="twitter" <?php echo $this->avatar_options['twitter'] == 'on' ? 'checked' : ''; ?> /></td> <td><small><label for="idTwitter"> <?php _e('Try to use <a href="http://twitter.com/" target="_blank">Twitter</a> avatar if no local is avatar defined.', 'avatars'); echo ' ', __('Order of precedence is; <i>Local</i>, <i>Twitter</i>, <i>Global</i>.', 'avatars'); ?> </label></small></td> </tr> <?php } if (!$this->networked) { ?> <tr> <td><?php _e('Gravatar default:', 'avatars'); ?> <br /><small><?php _e('Enhanced repeat from <i>Settings » Discussion</i>', 'avatars'); ?> </small></td> <td><?php echo get_avatar($wavatar, $this->avatar_options['size'], $wavatar); ?> </td> <td> <select name='wavatar'> <?php $avatar_defaults = array('custom' => __('none', 'avatars'), 'mystery' => __('Mystery Man'), 'blank' => __('Blank'), 'gravatar_default' => __('Gravatar Logo'), 'identicon' => __('Identicon'), 'wavatar' => __('Wavatar'), 'monsterid' => __('MonsterID'), 'retro' => __('Retro')); $avatar_defaults = apply_filters('avatar_defaults', $avatar_defaults); $avatar_list = ''; foreach ($avatar_defaults as $default_key => $default_name) { $selected = $wavatar == $default_key ? 'selected' : ''; $avatar_list .= "\n\t<option value='" . esc_attr($default_key) . "' {$selected} >" . $default_name . "</option>"; } echo apply_filters('default_avatar_select', $avatar_list); ?> </select> <br /> <small><?php _e('Give users without Global or Local avatars a unique avatar.', 'avatars'); ?> </small> </td> </tr> <?php } ?> <tr> <td><label for="idAvatarDefault"><?php _e('Default image:', 'avatars'); ?> </label></td> <td><?php echo get_avatar('', '', $this->avatar_options['default']); ?> </td> <td> <input type='text' name='default' id="idAvatarDefault" value='<?php echo $this->avatar_options['default']; ?> ' size='70' /> <br /> <small><?php _e('The default avatar (a working URI) for users without Global or Local avatars. Used for trackbacks.', 'avatars'); ?> </small> </td> </tr> <tr> <td><label for="idAvatarSnapshots"><?php _e('Use Snapshots:', 'avatars'); ?> </label></td> <td><input type="checkbox" id="idAvatarSnapshots" name="snapshots" <?php echo $this->avatar_options['snapshots'] == 'on' ? 'checked' : ''; ?> /></td> <td><label for="idAvatarSnapshots"><small><?php _e('If you have enabled', 'avatars'); ?> <a href="http://www.snap.com">snapshots</a>, <?php _e('clearing this will disable them for avatar links.', 'avatars'); ?> </small></label></td> </tr> <tr> <td><label for="idAvatarInPosts"><?php _e('Photos in posts:', 'avatars'); ?> </label></td> <td><input type="checkbox" name="in_posts" id="idAvatarInPosts" <?php echo $this->avatar_options['in_posts'] == 'on' ? 'checked' : ''; ?> /></td> <td><label for="idAvatarInPosts"><small><?php _e('Replaces', 'avatars'); ?> </small><code><!-- avatar <b>e-mail</b> --></code><small> <?php _e('with an avatar for that email address in post content.', 'avatars'); ?> </small></label></td> </tr> <tr> <td><label for="idAvatarUploadAllowed"><?php _e('User uploads:', 'avatars'); ?> </label></td> <td><input type="checkbox" id="idAvatarUploadAllowed" name="upload_allowed" <?php echo $this->avatar_options['upload_allowed'] == 'on' ? 'checked' : ''; ?> /></td> <td> <input type='text' id="idAvatarUploadDir" name='upload_dir' value='<?php echo $this->avatar_options['upload_dir']; ?> ' size='70' /> <br /> <small><label for="idAvatarUploadDir"><?php _e('If allowed, use this directory for user avatar uploads, e.g.', 'avatars'); ?> <code>/avatars</code>. <?php _e('Must have write access and is relative to ', 'avatars'); ?> <code><?php echo $this->avatar_root(); ?> </code>.</label></small> <br /> <label for="idAvatarLegacy">Or, use legacy (v7.3 and lower) <code>$_SERVER['DOCUMENT_ROOT']</code> method </label><input type="checkbox" id="idAvatarLegacy" name="legacy" <?php echo $this->avatar_options['legacy'] == 'on' ? 'checked' : ''; ?> />, <?php _e('this option often helps when using sub-domains.', 'avatars'); ?> </td> </tr> <tr> <td><label for="idAvatarResize"><?php _e('Resize uploads:', 'avatars'); ?> </label></td> <td><input type="checkbox" id="idAvatarResize" name="resize" <?php if ($this->avatar_options['upload_allowed'] != 'on') { echo 'disabled="true"'; } ?> <?php echo $this->avatar_options['resize'] == 'on' ? 'checked' : ''; ?> /></td> <td> <label for="idAvatarResize"><small><?php _e('Non-square uploads will be cropped.', 'avatars'); ?> </small></label> <br /> <input type="checkbox" id="idAvatarUpsize" name="upsize" <?php echo $this->avatar_options['upsize'] == 'on' ? 'checked' : ''; ?> /> <label for="idAvatarUpsize"><?php _e('pad images smaller than <i>resize</i> set below with a white background? This option stops small images becoming pixelated.'); ?> </label> </td> </tr> <tr> <td><label for="idAvatarResizeSize"><?php _e('Resize uploads size:', 'avatars'); ?> </label></td> <td><select name='scale' id="idAvatarResize" <?php if ($this->avatar_options['resize'] != 'on' || $this->avatar_options['upload_allowed'] != 'on') { echo 'disabled="true"'; } ?> ><?php if (empty($this->avatar_options['scale'])) { $def = true; } else { $def = false; } for ($i = $this->avatar_options['size']; $i <= 200; $i = $i + 10) { echo "<option value='{$i}'"; if ($i == $this->avatar_options['scale'] || $def && $i == SCALED_SIZE) { echo " selected"; } echo ">{$i}</option>"; } ?> </select></td> <td><label for="idAvatarResize">px</label></td> </tr> <tr> <?php if (file_exists(ABSPATH . '/wp-content/plugins/profile/avatars-widget.php')) { ?> <td><?php _e('Enable user profile widget:', 'avatars'); ?> </td> <td><input type="checkbox" name="widget_enabled" <?php echo $this->avatar_options['widget_enabled'] == 'on' ? 'checked' : ''; ?> /></td> <td><small><?php _e('Enable the user profile widget; configure the widget at <i>Appearance » Widgets</i>.', 'avatars'); ?> </small></td> <?php } else { ?> <td colspan="3"></td> <?php } ?> </tr> <tr> <td><label for="idWrapAvatar"><?php _e('Wrap Photos with URL:', 'avatars'); ?> </label></td> <td><input type="checkbox" id="idWrapAvatar" name="url_wrap" <?php echo $this->avatar_options['url_wrap'] == 'on' ? 'checked' : ''; ?> /></td> <td><small><label for="idWrapAvatar"><?php _e("Wrap Photo with URL (from User's profile or Comment form data).", 'avatars'); ?> </label></small></td> </tr> <tr> <td><label for="idNickName"><?php _e('Nickname:', 'avatars'); ?> </label></td> <td><input type="checkbox" name="name" <?php echo $this->avatar_options['name'] == 'on' ? 'checked' : ''; ?> id="idNickName" /></td> <td> <input type='text' name='location' value='<?php echo empty($this->avatar_options['location']) ? 'website' : $this->avatar_options['location']; ?> ' size='10' id="idNickLocation" /> <br /> <small><label for="idNickLocation"><?php _e("User's nickname used for avatar titles (tooltip).", 'avatars'); ?> </label></small> </td> </tr> </table> <p class="submit"><input type="submit" name="submit" class="button-primary" value="<?php _e('Update Photo Options', 'avatars'); ?> " /></p> </form> </div> <style type="text/css"> table.form-table td { border-bottom: 1px solid #e3e3e3; padding-bottom: 1.25em !important; vertical-align: top; } </style> <?php }
function get_default_search($array = array()) { $defaults = array('scope' => false, 'eventful' => false, 'eventless' => false); if (is_admin()) { //by default, we only get categories the owner can manage switch (get_option('dbem_permissions_categories')) { case 0: $defaults['owner'] = get_current_user_id(); break; case 1: $wp_user_search = new WP_User_Search(null, null, 'administrator'); $users = $wp_user_search->get_results(); $users[] = get_current_user_id(); $users[] = 0; $defaults['owner'] = implode(',', $users); break; case 2: $defaults['owner'] = false; break; } $defaults['owner'] = em_verify_admin() ? false : $defaults['owner']; } return apply_filters('em_categories_get_default_search', parent::get_default_search($defaults, $array), $array, $defaults); }
} }); }); }); </script> <div class="icon32" style="background: transparent url(<?php echo PHP_EXECUTION_BASE_URL; ?> /assets/icon.png) no-repeat"><br></div> <div class="wrap"> <form method="post"> <h2>PHP Execution</h2> <?php // Parse submissions if ($current_user_is_admin) { $search = new WP_User_Search(); // the roles to offered to add php execution permissions $role_names = array('administrator', 'editor', 'author', 'contributor', 'subscriber'); // ATTENTION: roles are ordered hierarchical: administrator => editor => author // if e.g. the role author gets granted php execution rights, all higher roles are also: i.e. administrator & editor $role_names = apply_filters('php_execution_hierarchical_roles', $role_names); $error = ''; $info = ''; if (count($_POST) > 0) { // setting role permissions if ($_POST['save_role_perms']) { // if role_perms is corrupt it will intval to 0 which means resetting to default only admin execution $new_role = intval($_POST['role_perms']); $granted = array(); for ($i = 0, $n = count($role_names); $i < $n; $i++) { $rolename = $role_names[$i];
if ( is_wp_error( $user_id ) ) $add_user_errors = $user_id; else { $new_user_login = apply_filters('pre_user_login', sanitize_user(stripslashes($_POST['user_login']), true)); $redirect = add_query_arg( array('usersearch' => urlencode($new_user_login), 'update' => $update), $redirect ); wp_redirect( $redirect . '#user-' . $user_id ); die(); } default: wp_enqueue_script('admin-users'); include('admin-header.php'); // Query the users $wp_user_search = new WP_User_Search($_GET['usersearch'], $_GET['userspage']); // Make the user objects foreach ( $wp_user_search->get_results() as $userid ) { $tmp_user = new WP_User($userid); $roles = $tmp_user->roles; $role = array_shift($roles); $roleclasses[$role][$tmp_user->user_login] = $tmp_user; } if ( isset($_GET['update']) ) : switch($_GET['update']) { case 'del': case 'del_many': ?> <?php $delete_count = (int) $_GET['delete_count']; ?>
break; } break; /* If a single role has been chosen to be deleted. */ /* If a single role has been chosen to be deleted. */ case 'delete': /* Verify the referer. */ check_admin_referer(members_get_nonce('edit-roles')); /* Send role deleted message. */ add_action('members_pre_edit_roles_form', 'members_message_role_deleted'); /* Get the default role. */ $default_role = get_option('default_role'); /* Get the role we want to delete. */ $role = $_GET['role']; /* Get all users with the role to be deleted. */ $wp_user_search = new WP_User_Search('', '', $role); $change_users = $wp_user_search->get_results(); /* If there are users with the role we're deleting, loop through them, remove the role, and set the default role. */ if (isset($change_users) && is_array($change_users)) { foreach ($change_users as $move_user) { $new_user = new WP_User($move_user); /* If the user has the role, remove it and set the default. Do we need this check? */ if ($new_user->has_cap($role)) { $new_user->remove_role($role); $new_user->set_role($default_role); } } } /* Remove the role. */ remove_role($role); /* Load the edit roles page. */
} $user_id = add_user(); $update = 'add'; if (is_wp_error($user_id)) { $add_user_errors = $user_id; } else { $new_user_login = apply_filters('pre_user_login', sanitize_user(stripslashes($_POST['user_login']), true)); $redirect = add_query_arg(array('usersearch' => urlencode($new_user_login), 'update' => $update), $redirect); wp_redirect($redirect . '#user-' . $user_id); die; } default: wp_enqueue_script('admin-users'); include 'admin-header.php'; // Query the users $wp_user_search = new WP_User_Search($_GET['usersearch'], $_GET['userspage']); // Make the user objects foreach ($wp_user_search->get_results() as $userid) { $tmp_user = new WP_User($userid); $roles = $tmp_user->roles; $role = array_shift($roles); $roleclasses[$role][$tmp_user->user_login] = $tmp_user; } if (isset($_GET['update'])) { switch ($_GET['update']) { case 'del': case 'del_many': ?> <?php $delete_count = (int) $_GET['delete_count']; ?>
/** Display a drop down lisy of administrator level users and optionally include a choice for Post Author */ function admin_dropdown($inc_author = false) { global $wpdb; $sql = "SELECT ID, display_name FROM {$wpdb->users} INNER JOIN {$wpdb->usermeta} ON {$wpdb->users}.ID = {$wpdb->usermeta}.user_id WHERE {$wpdb->usermeta}.meta_key='" . $wpdb->prefix . "user_level' AND {$wpdb->usermeta}.meta_value IN (8, 9, 10)"; $admins = $wpdb->get_results($sql); // handle issues from WordPress core where user_level is not set or set low if (empty($admins)) { $role = 'administrator'; if (!class_exists(WP_User_Search)) { require ABSPATH . 'wp-admin/includes/user.php'; } $wp_user_search = new WP_User_Search('', '', $role); $admins_string = implode(', ', $wp_user_search->get_results()); $sql = "SELECT ID, display_name FROM {$wpdb->users} WHERE ID IN (" . $admins_string . ")"; $admins = $wpdb->get_results($sql); } if ($inc_author) { $author[] = (object) array('ID' => 'author', 'display_name' => 'Post Author'); $admins = array_merge($author, $admins); } echo "<select name=\"sender\">\r\n"; foreach ($admins as $admin) { echo "<option value=\"" . $admin->ID . "\""; if ($admin->ID == $this->subscribe2_options['sender']) { echo " selected=\"selected\""; } echo ">" . $admin->display_name . "</option>\r\n"; } echo "</select>\r\n"; }