当前位置: 首页>>代码示例>>PHP>>正文


PHP get_users函数代码示例

本文整理汇总了PHP中get_users函数的典型用法代码示例。如果您正苦于以下问题:PHP get_users函数的具体用法?PHP get_users怎么用?PHP get_users使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了get_users函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: query_members

        function query_members()
        {
            global $wpdb;
            $show = isset($attr['show']) ? (int) $attr['show'] : 20;
            $orderby = isset($attr['orderby']) ? trim($attr['orderby']) : 'video';
            $order = isset($attr['order']) ? trim($attr['order']) : 'DESC';
            $user_array = array('number' => $show, 'orderby' => 'post_count', 'order' => 'DESC');
            $users = get_users($user_array);
            if (!empty($users)) {
                foreach ($users as $user) {
                    $user_data = get_user_by('id', $user->ID);
                    $content .= '
	                    <div class="channel-header">
							
							<div class="channel-image"><a href="' . get_author_posts_url($user->ID) . '">' . get_avatar($user->ID) . '</a></div>
							
							<div class="channel-info">
								<h3>' . $user_data->display_name . '</h3>
								
								<span class="channel-item"><strong>' . __('Videos:', 'mars') . '</strong> ' . mars_get_user_postcount($user->ID) . '</span>
								<span class="channel-item"><strong>' . __('Likes:', 'mars') . '</strong> ' . mars_get_user_metacount($user->ID, 'like_key') . '</span>
								<span class="channel-item"><strong>' . __('Views:', 'mars') . '</strong> ' . mars_get_user_metacount($user->ID, 'count_viewed') . '</span>
							</div>
						</div>
					';
                }
            }
            return $content;
        }
开发者ID:chypriote,项目名称:wp-video,代码行数:29,代码来源:Mars_Members_List.php

示例2: widget

 /**
  * Outputs the widget based on the arguments input through the widget controls.
  *
  * @since 0.1.0
  */
 function widget($args, $instance)
 {
     extract($args, EXTR_SKIP);
     /* Set up the arguments for get_users(). */
     $args = array('role' => $instance['role'], 'meta_key' => $instance['meta_key'], 'meta_value' => $instance['meta_value'], 'include' => !empty($instance['include']) ? explode(',', $instance['include']) : '', 'exclude' => !empty($instance['exclude']) ? explode(',', $instance['exclude']) : '', 'search' => $instance['search'], 'orderby' => $instance['orderby'], 'order' => $instance['order'], 'offset' => !empty($instance['offset']) ? intval($instance['offset']) : '', 'number' => !empty($instance['number']) ? intval($instance['number']) : '');
     /* Output the theme's $before_widget wrapper. */
     echo $before_widget;
     /* If a title was input by the user, display it. */
     if (!empty($instance['title'])) {
         echo $before_title . apply_filters('widget_title', $instance['title'], $instance, $this->id_base) . $after_title;
     }
     /* Get users. */
     $users = get_users($args);
     /* If users were found. */
     if (!empty($users)) {
         echo '<ul class="xoxo users">';
         /* Loop through each available user, creating a list item with a link to the user's archive. */
         foreach ($users as $user) {
             $url = get_author_posts_url($user->ID, $user->user_nicename);
             $class = "user-{$user->ID}";
             if (is_author($user->ID)) {
                 $class .= ' current-user';
             }
             echo "<li class='{$class}'><a href='{$url}' title='" . esc_attr($user->display_name) . "'>{$user->display_name}</a></li>\n";
         }
         echo '</ul>';
     }
     /* Close the theme's widget wrapper. */
     echo $after_widget;
 }
开发者ID:fwelections,项目名称:fwelections,代码行数:35,代码来源:widget-users.php

示例3: activate

 function activate()
 {
     global $wpdb;
     if (!get_option("lrp_database_establish")) {
         require_once ABSPATH . 'wp-admin/includes/upgrade.php';
         $table_name = $wpdb->prefix . "lrp_documents_history";
         $sql = "CREATE TABLE " . $table_name . " (\n\t\t\t\t  id bigint(20) NOT NULL AUTO_INCREMENT,\n\t\t\t\t  post bigint(20),\n\t\t\t\t  lrnode bigint(20),\n\t\t\t\t  lrkey bigint(20),\n\t\t\t\t  lrschema bigint(20),\n\t\t\t\t  lruser bigint(20),\n\t\t\t\t  lraction varchar(100),\n\t\t\t\t  lrdocid varchar(100),\n\t\t\t\t  date_submitted bigint(20),\n\t\t\t\t  UNIQUE KEY id(id)\n\t\t\t\t);";
         dbDelta($sql);
         add_option("lrp_database_establish", 1);
     }
     $get_users = get_users();
     foreach ($get_users as $user) {
         if (in_array("administrator", $user->roles)) {
             $user = new WP_User($user->data->ID);
             foreach ($this->AdministratorCapabilities as $capability) {
                 $user->add_cap($capability);
             }
         }
         if (in_array("editor", $user->roles)) {
             $user = new WP_User($user->data->ID);
             foreach ($this->EditorCapabilities as $capability) {
                 $user->add_cap($capability);
             }
         }
         if (in_array("author", $user->roles)) {
             $user = new WP_User($user->data->ID);
             foreach ($this->AuthorCapabilities as $capability) {
                 $user->add_cap($capability);
             }
         }
     }
 }
开发者ID:navnorth,项目名称:wp-learning-registry-publisher,代码行数:32,代码来源:learning-registry-publisher.php

示例4: widget

 function widget($args, $instance)
 {
     extract(array_merge(array('title' => ''), $instance));
     $authors = get_users(array('orderby' => 'post_count', 'order' => 'DESC'));
     if (isset($before_widget)) {
         echo $before_widget;
     }
     echo '<aside id="tt_authors_widget" class="widget tt-authors-widget tt-widget">';
     if ($title != '') {
         echo $args['before_title'] . $title . $args['after_title'];
     }
     echo '<ul>';
     foreach ($authors as $author) {
         echo '<li>';
         echo '<span class="widget-thumb">';
         echo get_avatar($author->ID, 55);
         echo '</span>';
         echo '<a href="' . get_author_posts_url($author->ID, $author->user_nicename) . '" class="widget-item-title" title="">' . $author->display_name . '</a>';
         echo '<ul>
                 <li class="comments-number"><a href="' . get_author_posts_url($author->ID, $author->user_nicename) . '" title="">' . count_user_posts($author->ID) . ' ' . (count_user_posts($author->ID) > 1 ? __('posts', 'themeton') : __('post', 'themeton')) . '</a></li>
               </ul>';
         echo '</li>';
     }
     echo '</ul>';
     echo '</aside>';
     if (isset($after_widget)) {
         echo $after_widget;
     }
     wp_reset_query();
 }
开发者ID:petersondrs,项目名称:tellura,代码行数:30,代码来源:authors_widget.php

示例5: include_professors

function include_professors()
{
    $admin_id = get_user_id_from_string(get_blog_option($current_blog->blog_id, 'admin_email'));
    $blog_major = get_user_major();
    //get_the_user_major($admin_id);
    //var_dump($blog_major);
    if ($GLOBALS['blog_id'] != 1) {
        //makes sure it's not the root blog
        $args = array('blog_id' => 1, 'role' => 'professor');
        $professors = get_users($args);
        //get all profs from root blog
        //loop through profs, add as user if same major, delete if different major
        foreach ($professors as $professor) {
            $prof_major = get_the_user_major($professor->ID);
            //var_dump($prof_major);
            if ($prof_major == $blog_major) {
                $current_role = get_the_user_role($professor);
                if ($current_role != 'Administrator') {
                    $result = add_existing_user_to_blog(array('user_id' => $professor->ID, 'role' => 'professor'));
                }
            } else {
                $result = remove_user_from_blog($professor->ID, $current_blog->blog_id);
            }
        }
    }
    //end if
}
开发者ID:ryanshoover,项目名称:seufolios,代码行数:27,代码来源:role_setup.php

示例6: acfw_activate

function acfw_activate()
{
    $users = get_users('meta_key=acfw_dismiss_expired');
    foreach ($users as $user) {
        delete_user_meta($user->id, 'acfw_dismiss_expired');
    }
}
开发者ID:nusserstudios,项目名称:acf-widgets,代码行数:7,代码来源:acf-widgets.php

示例7: draw_user_list

function draw_user_list()
{
    $users = get_users();
    ?>
      <table class="userlist table table-condensed table-bordered">
        <tr>
          <th>Last Name</th>
          <th>First Name</th>
          <th>Username</th>
        </tr>
        <?php 
    while ($row = $users->fetch_array()) {
        $row['role'] = get_role($row['user_id']);
        echo '<tr class="userlist ';
        echo 'userlist-' . $row['role'];
        if ($row['inactive']) {
            echo ' userlist-inactive';
        }
        echo '" onclick="openEdit(' . $row['user_id'] . ')">';
        echo '<td style="cursor:pointer;">' . $row['lname'] . "</td>";
        echo '<td style="cursor:pointer;">' . $row['fname'] . "</td>";
        echo '<td style="cursor:pointer;">' . $row['username'] . "</td>";
        echo '</tr>';
    }
    ?>
      </table>
  <?php 
}
开发者ID:rogerapras,项目名称:php_timeclock,代码行数:28,代码来源:manage_users.php

示例8: bp_blogs_record_existing_blogs

/**
 * Populates the BP blogs table with existing blogs.
 *
 * @package BuddyPress Blogs
 *
 * @global object $bp BuddyPress global settings
 * @global object $wpdb WordPress database object
 * @uses get_users()
 * @uses bp_blogs_record_blog()
 */
function bp_blogs_record_existing_blogs()
{
    global $bp, $wpdb;
    // Truncate user blogs table and re-record.
    $wpdb->query("TRUNCATE TABLE {$bp->blogs->table_name}");
    if (is_multisite()) {
        $blog_ids = $wpdb->get_col($wpdb->prepare("SELECT blog_id FROM {$wpdb->base_prefix}blogs WHERE mature = 0 AND spam = 0 AND deleted = 0"));
    } else {
        $blog_ids = 1;
    }
    if ($blog_ids) {
        foreach ((array) $blog_ids as $blog_id) {
            $users = get_users(array('blog_id' => $blog_id));
            $subscribers = get_users(array('blog_id' => $blog_id, 'role' => 'subscriber'));
            if (!empty($users)) {
                foreach ((array) $users as $user) {
                    // Don't record blogs for subscribers
                    if (!in_array($user, $subscribers)) {
                        bp_blogs_record_blog($blog_id, $user->ID, true);
                    }
                }
            }
        }
    }
}
开发者ID:vsalx,项目名称:rattieinfo,代码行数:35,代码来源:bp-blogs-functions.php

示例9: widget

 function widget($args, $instance)
 {
     extract($args, EXTR_SKIP);
     $instance = wp_parse_args((array) $instance, array('title' => __('Blog Authors', 'academy'), 'number' => '6', 'order' => 'registered'));
     $orderdir = 'DESC';
     if ($instance['order'] == 'display_name') {
         $orderdir = 'ASC';
     }
     $title = apply_filters('widget_title', empty($instance['title']) ? __('Blog Authors', 'academy') : $instance['title'], $instance, $this->id_base);
     $out = $before_widget;
     $out .= $before_title . $title . $after_title;
     $counter = 0;
     $users = get_users(array('number' => $instance['number'], 'orderby' => $instance['order'], 'order' => $orderdir));
     $out .= '<div class="users-listing">';
     foreach ($users as $user) {
         $name = trim($user->first_name . ' ' . $user->last_name);
         $counter++;
         $out .= '<div class="user-image ';
         if ($counter == 3) {
             $out .= 'last';
         }
         $out .= '"><div class="bordered-image">';
         $out .= '<a title="' . $name . '" href="' . get_author_posts_url($user->ID) . '">' . get_avatar($user->ID) . '</a>';
         $out .= '</div></div>';
         if ($counter == 3) {
             $out .= '<div class="clear"></div>';
             $counter = 0;
         }
     }
     $out .= '</div>';
     $out .= $after_widget;
     echo $out;
 }
开发者ID:rinodung,项目名称:wordpress-demo,代码行数:33,代码来源:themex.authors.php

示例10: simpleSubscribeUninstall

/**
 * Uninstall function
 */
function simpleSubscribeUninstall()
{
    global $wpdb;
    /**
     * 1. Prepare tables to be deleted, go thru tables, check if they exist, and remove
     */
    $removeTables = array($wpdb->prefix . "subscribers", $wpdb->prefix . "subscribers_log");
    foreach ($removeTables as $table) {
        $wpdb->query("DROP TABLE IF EXISTS `" . $table . "`");
    }
    /**
     * 2. Delete simple subcribe options
     */
    delete_option('simpleSubscribe');
    /**
     * 3. Delete user meta
     */
    $registeredUsers = get_users(array('meta_key' => 'subscription', 'meta_value' => 1));
    if (!empty($registeredUsers)) {
        foreach ($registeredUsers as $user) {
            delete_user_meta($user->data->ID, 'subscription');
            delete_user_meta($user->data->ID, 'subscribersPerPage');
        }
    }
}
开发者ID:ntamvl,项目名称:planningelegance,代码行数:28,代码来源:uninstall.php

示例11: bnfw_render_users_dropdown

/**
 * Render users dropdown.
 *
 * @since 1.3.6
 */
function bnfw_render_users_dropdown($selected_users)
{
    global $wp_roles;
    ?>
		<optgroup label="User Roles">
	<?php 
    $roles = $wp_roles->get_names();
    foreach ($roles as $role) {
        $selected = selected(true, in_array('role-' . $role, $selected_users), false);
        echo '<option value="role-', $role, '" ', $selected, '>', $role, '</option>';
    }
    ?>
		</optgroup>
		<optgroup label="Users">
	<?php 
    $user_count = count_users();
    // if there are more than 100 users then use AJAX to load them dynamically.
    // So just get only the selected users
    if (count($selected_users) > 0 && $user_count['total_users'] > 100) {
        $users = get_users(array('include' => $selected_users, 'order_by' => 'email', 'fields' => array('ID', 'user_login')));
    } else {
        $users = get_users(array('order_by' => 'email', 'number' => 100, 'fields' => array('ID', 'user_login')));
    }
    foreach ($users as $user) {
        $selected = selected(true, in_array($user->ID, $selected_users), false);
        echo '<option value="', $user->ID, '" ', $selected, '>', $user->user_login, '</option>';
    }
}
开发者ID:alvarpoon,项目名称:aeg,代码行数:33,代码来源:helpers.php

示例12: load_users

 /**
  * Generates array of users indexed by user ID, and
  * an array of user_nicenames, indexed by user ID.
  *
  * @compat < 3.1: Use $wpdb and get_users of blog.
  */
 function load_users()
 {
     global $wpdb;
     // < 3.1
     // Cache the user information.
     if (!empty($this->users)) {
         return $this->users;
     }
     if (function_exists('get_users')) {
         // >= 3.1
         $users = get_users();
         foreach ($users as $user) {
             $this->users[$user->ID] = $user;
             $this->names[$user->ID] = $user->user_nicename;
         }
     } else {
         //  < 3.1
         $users = get_users_of_blog();
         $user_ids = '';
         foreach ($users as $user) {
             $this->users[$user->ID] = $user;
             $user_ids .= $user->ID;
         }
         foreach ($wpdb->get_results("SELECT ID, user_nicename from {$wpdb->users} WHERE ID IN({$user_ids})") as $user) {
             $this->users[$user->ID]->user_nicename = $user->user_nicename;
             $this->names[$user->ID] = $user->user_nicename;
         }
     }
     return $this->users;
 }
开发者ID:rajbot,项目名称:tikirobot_p2,代码行数:36,代码来源:mentions.php

示例13: ffck_check_user

function ffck_check_user($member_data)
{
    //look for a wordpress user with same licence id
    echo $member_data['firstname'] . ' ' . $member_data['lastname'] . ' ';
    $existing_users = get_users(array('meta_key' => 'FFCK_licence', 'meta_value' => $member_data['licence_id']));
    if (sizeof($existing_users) > 1) {
        echo "ERROR multiple matches for licence " . $member_data['licence_id'];
    } elseif (sizeof($existing_users) == 1) {
        //licence id match. update account
        echo "Updating... ";
        ffck_update_user($existing_users[0], $member_data);
    } else {
        //look for a wordpress user with same email
        $existing_users = get_users(array('search' => $member_data['email']));
        //for each match,
        foreach ($existing_users as $existing_user) {
            //different licence_id, skip
            if ($existing_user->has_prop('ffck_licence') && strcmp($existing_user->get('ffck_licence'), $member_data['licence_id']) != 0) {
                echo "Skipping " . $existing_user->first_name . ", ";
                continue;
            } else {
                if (!$existing_user->has_prop('ffck_licence')) {
                    echo "Updating... ";
                    ffck_update_user($existing_user, $member_data);
                    echo PHP_EOL;
                    return;
                }
            }
        }
        //no matching user, create new one
        echo "Creating... ";
        ffck_create_user($member_data);
    }
    echo PHP_EOL;
}
开发者ID:thomaswillecomme,项目名称:ffck_users_sync,代码行数:35,代码来源:actions.php

示例14: members_delete_role

/**
 * Function for safely deleting a role and transferring the deleted role's users to the default
 * role.  Note that this function can be extremely intensive.  Whenever a role is deleted, it's
 * best for the site admin to assign the user's of the role to a different role beforehand.
 *
 * @since  0.2.0
 * @access public
 * @param  string  $role
 * @return void
 */
function members_delete_role($role)
{
    // Get the default role.
    $default_role = get_option('default_role');
    // Don't delete the default role. Site admins should change the default before attempting to delete the role.
    if ($role == $default_role) {
        return;
    }
    // Get all users with the role to be deleted.
    $users = get_users(array('role' => $role));
    // Check if there are any users with the role we're deleting.
    if (is_array($users)) {
        // If users are found, loop through them.
        foreach ($users as $user) {
            // If the user has the role and no other roles, set their role to the default.
            if ($user->has_cap($role) && 1 >= count($user->roles)) {
                $user->set_role($default_role);
            } else {
                if ($user->has_cap($role)) {
                    $user->remove_role($role);
                }
            }
        }
    }
    // Remove the role.
    remove_role($role);
    // Remove the role from the role factory.
    members_role_factory()->remove_role($role);
}
开发者ID:vunh1989,项目名称:vodphoto,代码行数:39,代码来源:functions-admin.php

示例15: notify_new_topic

 /**
  * Notify user roles on new topic
  */
 public function notify_new_topic($topic_id = 0, $forum_id = 0, $anonymous_data = 0, $topic_author = 0)
 {
     $user_roles = Falcon::get_option('bbsub_topic_notification', array());
     // bail out if no user roles found
     if (!$user_roles) {
         return;
     }
     $recipients = array();
     foreach ($user_roles as $role) {
         $users = get_users(array('role' => $role, 'fields' => array('ID', 'user_email', 'display_name')));
         $recipients = array_merge($recipients, $users);
     }
     // still no users?
     if (!$recipients) {
         return;
     }
     // subscribe the users automatically
     foreach ($recipients as $user) {
         bbp_add_user_subscription($user->ID, $topic_id);
     }
     // Sanitize the HTML into text
     $content = apply_filters('bbsub_html_to_text', bbp_get_topic_content($topic_id));
     // Build email
     $text = "%1\$s\n\n";
     $text .= "---\nReply to this email directly or view it online:\n%2\$s\n\n";
     $text .= "You are receiving this email because you subscribed to it. Login and visit the topic to unsubscribe from these emails.";
     $text = sprintf($text, $content, bbp_get_topic_permalink($topic_id));
     $text = apply_filters('bbsub_topic_email_message', $text, $topic_id, $content);
     $subject = apply_filters('bbsub_topic_email_subject', 'Re: [' . get_option('blogname') . '] ' . bbp_get_topic_title($topic_id), $topic_id);
     $options = array('author' => bbp_get_topic_author_display_name($topic_id), 'id' => $topic_id);
     $this->handler->send_mail($recipients, $subject, $text, $options);
     do_action('bbp_post_notify_topic_subscribers', $topic_id, $recipients);
 }
开发者ID:rmccue,项目名称:Falcon,代码行数:36,代码来源:bbPress.php


注:本文中的get_users函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。