コード例 #1
0
        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;
        }
コード例 #2
0
 /**
  * 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;
 }
 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);
             }
         }
     }
 }
コード例 #4
0
 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();
 }
コード例 #5
0
ファイル: role_setup.php プロジェクト: ryanshoover/seufolios
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
}
コード例 #6
0
function acfw_activate()
{
    $users = get_users('meta_key=acfw_dismiss_expired');
    foreach ($users as $user) {
        delete_user_meta($user->id, 'acfw_dismiss_expired');
    }
}
コード例 #7
0
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 
}
コード例 #8
0
/**
 * 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);
                    }
                }
            }
        }
    }
}
コード例 #9
0
 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;
 }
コード例 #10
0
ファイル: uninstall.php プロジェクト: ntamvl/planningelegance
/**
 * 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');
        }
    }
}
コード例 #11
0
ファイル: helpers.php プロジェクト: alvarpoon/aeg
/**
 * 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>';
    }
}
コード例 #12
0
ファイル: mentions.php プロジェクト: rajbot/tikirobot_p2
 /**
  * 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;
 }
コード例 #13
0
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;
}
コード例 #14
0
ファイル: functions-admin.php プロジェクト: vunh1989/vodphoto
/**
 * 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);
}
コード例 #15
0
ファイル: bbPress.php プロジェクト: rmccue/Falcon
 /**
  * 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);
 }
コード例 #16
0
ファイル: auth-qq.php プロジェクト: yarec/wp-oauth
function qq_oauth()
{
    $code = $_GET['code'];
    $token_url = "https://graph.qq.com/oauth2.0/token?client_id=" . QQ_APPID . "&client_secret=" . QQ_APPSECRET . "&grant_type=authorization_code&redirect_uri=" . urlencode(home_url()) . "&code=" . $code;
    $response = wp_remote_get($token_url);
    $response = $response['body'];
    if (strpos($response, "callback") !== false) {
        wp_redirect(home_url());
    }
    $params = array();
    parse_str($response, $params);
    $qq_access_token = $params["access_token"];
    $graph_url = "https://graph.qq.com/oauth2.0/me?access_token=" . $qq_access_token;
    $str = wp_remote_get($graph_url);
    $str = $str['body'];
    if (strpos($str, "callback") !== false) {
        $lpos = strpos($str, "(");
        $rpos = strrpos($str, ")");
        $str = substr($str, $lpos + 1, $rpos - $lpos - 1);
    }
    $user = json_decode($str, true);
    if (isset($user->error)) {
        echo "<h3>错误代码:</h3>" . $user->error;
        echo "<h3>信息  :</h3>" . $user->error_description;
        exit;
    }
    $qq_openid = $user['openid'];
    if (!$qq_openid) {
        wp_redirect(home_url());
        exit;
    }
    $get_user_info = "https://graph.qq.com/user/get_user_info?" . "access_token=" . $qq_access_token . "&oauth_consumer_key=" . QQ_APPID . "&openid=" . $qq_openid . "&format=json";
    $data = wp_remote_get($get_user_info);
    $data = $data['body'];
    $data = json_decode($data, true);
    $username = $data['nickname'];
    $avatar = $data['figureurl_2'];
    if (is_user_logged_in()) {
        $this_user = wp_get_current_user();
        update_user_meta($this_user->ID, "qq_openid", $qq_openid);
        update_user_meta($this_user->ID, "qq_avatar", $avatar);
        fa_qq_oauth_redirect();
    } else {
        $user_qq = get_users(array("meta_key " => "qq_openid", "meta_value" => $qq_openid));
        if (is_wp_error($user_qq) || !count($user_qq)) {
            $login_name = wp_create_nonce($qq_openid);
            $random_password = wp_generate_password($length = 12, $include_standard_special_chars = false);
            $userdata = array('user_login' => $login_name, 'display_name' => $username, 'user_pass' => $random_password, 'nick_name' => $username);
            $user_id = wp_insert_user($userdata);
            wp_signon(array("user_login" => $login_name, "user_password" => $random_password), false);
            update_user_meta($user_id, "qq_openid", $qq_openid);
            update_user_meta($user_id, "qq_avatar", $avatar);
            fa_qq_oauth_redirect();
        } else {
            wp_set_auth_cookie($user_qq[0]->ID);
            update_user_meta($user_qq[0]->ID, "qq_avatar", $avatar);
            fa_qq_oauth_redirect();
        }
    }
}
コード例 #17
0
 public static function send_activity_report()
 {
     $current_time = current_time('timestamp');
     $mostly_recent_users = get_users(array('meta_key' => 'displet_last_login', 'meta_value' => $current_time - 60 * 60 * 24 * 7, 'meta_compare' => '>'));
     $recent_users = array();
     if (!empty($mostly_recent_users) && is_array($mostly_recent_users)) {
         $edit_url = admin_url('admin.php?page=displet-lead-manager&user_id=');
         foreach ($mostly_recent_users as $user) {
             if (!empty($user->displet_last_login) && is_numeric($user->displet_last_login)) {
                 $logins_for_day = 0;
                 if (!empty($user->displet_logins) && is_array($user->displet_logins)) {
                     foreach ($user->displet_logins as $login) {
                         if ($login > $current_time - 60 * 60 * 24) {
                             $logins_for_day++;
                         }
                     }
                 }
                 $property_stats = DispletRetsIdxViewedPropertiesController::get_property_view_stats($user->displet_user_properties);
                 $recent_users[] = array('url' => $edit_url . $user->ID, 'name' => $user->nickname, 'phone' => $user->displet_phone, 'logins_for_day' => $logins_for_day, 'logins_total' => count($user->displet_logins), 'price_average' => $property_stats['price_average'], 'zip_mode' => $property_stats['zip_mode']);
             }
         }
     }
     if (!empty($recent_users)) {
         $user_activity_report = '<table cellpadding="3" width="100%"><tr><th>Name</th><th>Phone</th><th>Logins In Last Day</th><th>Total Logins</th><th>Average Price</th><th>Most Frequented Zip Code</th></tr>';
         foreach ($recent_users as $user) {
             $price_average = !empty($user['price_average']) ? number_format($user['price_average']) : '';
             $user_activity_report .= '<tr><td align="left"><a href="' . $user['url'] . '">' . $user['name'] . '</a></td><td align="center">' . $user['phone'] . '</td><td align="center">' . $user['logins_for_day'] . '</td><td align="center">' . $user['logins_total'] . '</td><td align="center">$' . $price_average . '</td><td align="center">' . $user['zip_mode'] . '</td></tr>';
         }
         $user_activity_report .= '</table>';
         new DispletRetsIdxEmail('activity_report', array('activity_report' => $user_activity_report));
     }
 }
コード例 #18
0
 static function check_user_exists($username)
 {
     global $wpdb;
     //if username is empty just return false
     if ($username == '') {
         return false;
     }
     //If multisite
     if (AIOWPSecurity_Utility::is_multisite_install()) {
         $blog_id = get_current_blog_id();
         $admin_users = get_users('blog_id=' . $blog_id . 'orderby=login&role=administrator');
         $acct_name_exists = false;
         foreach ($admin_users as $user) {
             if ($user->user_login == $username) {
                 $acct_name_exists = true;
                 break;
             }
         }
         return $acct_name_exists;
     }
     //check users table
     //$user = $wpdb->get_var( "SELECT user_login FROM `" . $wpdb->users . "` WHERE user_login='******';" );
     $sql_1 = $wpdb->prepare("SELECT user_login FROM {$wpdb->users} WHERE user_login=%s", sanitize_text_field($username));
     $user = $wpdb->get_var($sql_1);
     $sql_2 = $wpdb->prepare("SELECT ID FROM {$wpdb->users} WHERE ID=%s", sanitize_text_field($username));
     $userid = $wpdb->get_var($sql_2);
     if ($user == $username || $userid == $username) {
         return true;
     } else {
         return false;
     }
 }
コード例 #19
0
 function get_users()
 {
     $return['users'] = get_users();
     $response = new WP_JSON_Response();
     $response->set_data($return);
     return $response;
 }
コード例 #20
0
ファイル: meta-box.php プロジェクト: raindolf/Kasemor
 function estate_register_meta_boxes($meta_boxes)
 {
     $prefix = 'estate_';
     $agents = array('' => __('None', 'tt'));
     // Get all users with role "agent"
     $all_agents = get_users(array('role' => 'agent', 'fields' => 'ID'));
     foreach ($all_agents as $agent) {
         $agents[$agent] = get_user_meta($agent, 'first_name', true) . ' ' . get_user_meta($agent, 'last_name', true);
     }
     /* PROPERTY
     		============================== */
     $meta_boxes[] = array('id' => 'property_settings', 'title' => __('Property Settings', 'tt'), 'pages' => array('property'), 'context' => 'normal', 'priority' => 'high', 'autosave' => true, 'fields' => array(array('name' => __('Property Layout', 'tt'), 'id' => "{$prefix}property_layout", 'desc' => __('Choose Property Layout.', 'tt'), 'type' => 'select', 'options' => array('theme_option_setting' => __('Theme Option Setting', 'tt'), 'full_width' => __('Full Width', 'tt'), 'boxed' => __('Boxed', 'tt')), 'std' => 'theme_option_setting'), array('name' => __('Property Status Update', 'tt'), 'id' => "{$prefix}property_status_update", 'desc' => __('E.g. "Sold", "Rented Out" etc.', 'tt'), 'type' => 'text', 'std' => __('', 'tt')), array('name' => __('Featured Property', 'tt'), 'id' => "{$prefix}property_featured", 'type' => 'checkbox', 'std' => 0), array('name' => __('Property Video Provider', 'tt'), 'id' => "{$prefix}property_video_provider", 'desc' => __('', 'tt'), 'type' => 'select', 'options' => array('none' => __('None', 'tt'), 'youtube' => __('YouTube', 'tt'), 'vimeo' => __('Vimeo', 'tt'))), array('name' => __('Property Video ID', 'tt'), 'id' => "{$prefix}property_video_id", 'desc' => __('', 'tt'), 'type' => 'text', 'std' => __('', 'tt')), array('name' => __('Property Images', 'tt'), 'id' => "{$prefix}property_images", 'type' => 'image_advanced', 'max_file_uploads' => 100), array('name' => __('Property ID', 'tt'), 'id' => "{$prefix}property_id", 'desc' => __('', 'tt'), 'type' => 'text', 'std' => __('', 'tt')), array('name' => __('Address', 'tt'), 'id' => "{$prefix}property_address", 'desc' => __('', 'tt'), 'type' => 'text', 'std' => __('', 'tt')), array('id' => "{$prefix}property_location", 'name' => __('Google Maps', 'tt'), 'desc' => __('Enter Property Address Above, Then Click "Find Address" To Search For Exact Location On The Map. Drag & Drop Map Marker If Necessary.', 'tt'), 'type' => 'map', 'std' => '', 'style' => 'width: 400px; height: 200px; margin-bottom: 1em', 'address_field' => "{$prefix}property_address"), array('name' => __('Available From', 'tt'), 'id' => "{$prefix}property_available_from", 'type' => 'date', 'js_options' => array('appendText' => __('(YYYYMMDD)', 'tt'), 'dateFormat' => __('yymmdd', 'tt'), 'changeMonth' => true, 'changeYear' => true, 'showButtonPanel' => false)), array('name' => __('Property Price Prefix', 'tt'), 'id' => "{$prefix}property_price_prefix", 'desc' => __('Appears Before Property Price (i.e. "from")', 'tt'), 'type' => 'text', 'std' => __('', 'tt')), array('name' => __('Property Price', 'tt'), 'id' => "{$prefix}property_price", 'desc' => __('Digits Only. Enter "-1" for "Price Upon Request"', 'tt'), 'type' => 'number', 'std' => __('1000', 'tt'), 'step' => 0.01, 'min' => '-1'), array('name' => __('Property Price Suffix', 'tt'), 'id' => "{$prefix}property_price_text", 'desc' => __('Appears After Property Price (i.e. "per month")', 'tt'), 'type' => 'text', 'std' => __('', 'tt')), array('name' => __('Size', 'tt'), 'id' => "{$prefix}property_size", 'desc' => __('Property Size (Digits Only, i.e. "250")', 'tt'), 'type' => 'number', 'std' => __('250', 'tt'), 'step' => 0.01), array('name' => __('Size Unit', 'tt'), 'id' => "{$prefix}property_size_unit", 'desc' => __('Unit Appears After Property Size (i.e. "sq ft")', 'tt'), 'type' => 'text', 'std' => __('sq ft', 'tt')), array('name' => __('Rooms', 'tt'), 'id' => "{$prefix}property_rooms", 'type' => 'number', 'prefix' => __('', 'tt'), 'suffix' => __('', 'tt'), 'min' => 0, 'step' => 0.5), array('name' => __('Bedrooms', 'tt'), 'id' => "{$prefix}property_bedrooms", 'type' => 'number', 'prefix' => __('', 'tt'), 'suffix' => __('', 'tt'), 'min' => 0, 'step' => 0.5), array('name' => __('Bathrooms', 'tt'), 'id' => "{$prefix}property_bathrooms", 'type' => 'number', 'prefix' => __('', 'tt'), 'suffix' => __('', 'tt'), 'min' => 0, 'step' => 0.5), array('name' => __('Garages', 'tt'), 'id' => "{$prefix}property_garages", 'type' => 'number', 'prefix' => __('', 'tt'), 'suffix' => __('', 'tt'), 'min' => 0, 'step' => 0.5), array('name' => __('Contact Information', 'tt'), 'id' => "{$prefix}property_contact_information", 'type' => 'select', 'options' => array('all' => __('Profile Information & Contact Form', 'tt'), 'form' => __('Contact Form Only', 'tt'), 'none' => __('None', 'tt')), 'std' => 'all'), array('name' => __('Assign Agent', 'tt'), 'id' => "{$prefix}property_custom_agent", 'desc' => __('Selected agent will be able to edit this property.', 'tt'), 'type' => 'select', 'options' => $agents), array('name' => __('Internal Note', 'tt'), 'id' => "{$prefix}internal_note", 'desc' => __('Note for internal use. Won\'t appear on the frontend.', 'tt'), 'type' => 'textarea', 'std' => __('', 'tt')), array('name' => __('Attachments', 'tt'), 'id' => "{$prefix}property_attachments", 'desc' => __('', 'tt'), 'type' => 'file_advanced', 'std' => __('', 'tt'))));
     /* TESTIMONIAL
     		============================== */
     $meta_boxes[] = array('id' => 'testimonial_settings', 'title' => __('Testimonial', 'tt'), 'pages' => array('testimonial'), 'context' => 'normal', 'priority' => 'high', 'autosave' => true, 'fields' => array(array('name' => __('Testimonial Text', 'tt'), 'id' => "{$prefix}testimonial_text", 'type' => 'textarea', 'std' => __('', 'tt'))));
     /* POST TYPE "GALLERY"
     		============================== */
     $meta_boxes[] = array('id' => 'post_type_gallery', 'title' => __('Gallery Settings', 'tt'), 'pages' => array('post'), 'context' => 'normal', 'priority' => 'high', 'autosave' => true, 'fields' => array(array('name' => __('Gallery Images', 'tt'), 'id' => "{$prefix}post_gallery", 'type' => 'image_advanced', 'max_file_uploads' => 100)));
     /* POST TYPE "VIDEO"
     		============================== */
     $meta_boxes[] = array('id' => 'post_type_video', 'title' => __('Video Settings', 'tt'), 'pages' => array('post'), 'context' => 'normal', 'priority' => 'high', 'autosave' => true, 'fields' => array(array('name' => 'Full Video URL', 'id' => "{$prefix}post_video_url", 'desc' => 'Insert Full Video URL (i.e. <strong>http://vimeo.com/99370876</strong>)', 'type' => 'text', 'std' => '')));
     /* PAGE SETTINGS
     		============================== */
     $meta_boxes[] = array('id' => 'pages_settings', 'title' => __('Page Settings', 'tt'), 'pages' => array('post', 'page', 'property', 'agent'), 'context' => 'normal', 'priority' => 'high', 'autosave' => true, 'fields' => array(array('name' => __('Hide Sidebar', 'tt'), 'id' => "{$prefix}page_hide_sidebar", 'type' => 'checkbox', 'std' => 0), array('name' => __('Intro Fullscreen Background Slideshow Images', 'tt'), 'id' => "{$prefix}intro_fullscreen_background_slideshow_images", 'class' => 'intro-only', 'type' => 'image_advanced', 'max_file_uploads' => 100)));
     // Page Template "Property - Slideshow"
     $meta_boxes[] = array('id' => 'slideshow_settings', 'title' => __('Slideshow Settings', 'tt'), 'pages' => array('page'), 'context' => 'normal', 'priority' => 'high', 'autosave' => true, 'fields' => array(array('name' => __('Type', 'tt'), 'id' => "{$prefix}property_slideshow_type", 'desc' => __('', 'tt'), 'type' => 'select', 'options' => array('featured' => __('Featured Properties', 'tt'), 'latest' => __('Latest Three Properties', 'tt'), 'selected' => __('Selected Properties (choose below)', 'tt')), 'std' => 'latest'), array('name' => __('Selected Properties', 'tt'), 'id' => "{$prefix}property_slideshow_selected_properties", 'type' => 'post', 'post_type' => 'property', 'field_type' => 'select_advanced', 'multiple' => true, 'query_args' => array('post_status' => 'publish', 'posts_per_page' => '-1')), array('name' => __('Property Search', 'tt'), 'id' => "{$prefix}property_slideshow_search", 'desc' => __('Setup in Theme Options Panel', 'tt'), 'type' => 'radio', 'options' => array('none' => __('No Search', 'tt'), 'custom' => __('Property Search', 'tt'), 'mini' => __('Property Search Mini', 'tt')))));
     // Page Template "Property - Map"
     $meta_boxes[] = array('id' => 'property_map_settings', 'title' => __('Property Map Settings', 'tt'), 'pages' => array('page'), 'context' => 'normal', 'priority' => 'high', 'autosave' => true, 'fields' => array(array('name' => __('Property Location', 'tt'), 'id' => "{$prefix}property_map_location", 'desc' => __('', 'tt'), 'type' => 'taxonomy_advanced', 'options' => array('taxonomy' => 'property-location', 'type' => 'select_advanced', 'args' => array())), array('name' => __('Property Status', 'tt'), 'id' => "{$prefix}property_map_status", 'desc' => __('', 'tt'), 'type' => 'taxonomy_advanced', 'options' => array('taxonomy' => 'property-status', 'type' => 'checkbox_list', 'args' => array())), array('name' => __('Property Type', 'tt'), 'id' => "{$prefix}property_map_type", 'desc' => __('', 'tt'), 'type' => 'taxonomy_advanced', 'options' => array('taxonomy' => 'property-type', 'type' => 'checkbox_list', 'args' => array())), array('name' => __('Custom Zoom Level', 'tt'), 'id' => "{$prefix}property_map_custom_zoom_level", 'desc' => __('Enter only, if your properties are located very closeby, and you would like to zoom closer. Zoom targets oldest property.', 'tt'), 'type' => 'number', 'step' => 1, 'min' => 0)));
     return $meta_boxes;
 }
コード例 #21
0
ファイル: wp-post.php プロジェクト: juanfra/fakerpress
 public function post_author($haystack = array())
 {
     if (empty($haystack)) {
         $haystack = get_users(array('blog_id' => get_current_blog_id(), 'count_total' => false, 'fields' => 'ID'));
     }
     return $this->generator->randomElement((array) $haystack);
 }
コード例 #22
0
/**
 * Retrieve a list of all clients
 *
 * @param	str|arr	$roles		Optional: The roles for which we want to retrieve the clients from.
 *			int		$employee	Optional: Only display clients of the given employee
 *			str		$orderby	Optional: The field by which to order. Default display_name
 *			str		$order		Optional: ASC (default) | Desc
 *
 * @return	$arr	$clients	or false if no clients for the specified roles
 */
function mdjm_get_clients($roles = array('client', 'inactive_client'), $employee = false, $orderby = 'display_name', $order = 'ASC')
{
    // We'll work with an array of roles
    if (!empty($roles) && !is_array($roles)) {
        $roles = array($roles);
    }
    $client_args = apply_filters('mdjm_get_clients_args', array('role__in' => $roles, 'orderby' => $orderby, 'order' => $order));
    $all_clients = get_users($client_args);
    // If we are only quering an employee's client, we need to filter
    if (!empty($employee)) {
        foreach ($all_clients as $client) {
            if (!MDJM()->users->is_employee_client($client->ID, $employee)) {
                continue;
            }
            $clients[] = $client;
        }
        // No clients for employee
        if (empty($clients)) {
            return false;
        }
        $all_clients = $clients;
    }
    $clients = $all_clients;
    return $clients;
}
コード例 #23
0
 /**
  * Outputs the widget based on the arguments input through the widget controls.
  *
  * @since  0.1.0
  * @access public
  * @param  array  $sidebar
  * @param  array  $instance
  * @return void
  */
 function widget($sidebar, $instance)
 {
     $instance = wp_parse_args($instance, $this->defaults);
     // 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 $sidebar['before_widget'];
     // If a title was input by the user, display it.
     if ($instance['title']) {
         echo $sidebar['before_title'] . apply_filters('widget_title', $instance['title'], $instance, $this->id_base) . $sidebar['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) {
             $class = sanitize_html_class("user-{$user->ID}");
             if (is_author($user->ID)) {
                 $class .= ' current-user';
             }
             printf('<li class="%s"><a href="%s">%s</a>', esc_attr($class), esc_url(get_author_posts_url($user->ID, $user->user_nicename)), esc_html($user->display_name));
         }
         echo '</ul>';
     }
     // Close the theme's widget wrapper.
     echo $sidebar['after_widget'];
 }
	public function run( $arguments ) {

		$itsec_two_factor = new ITSEC_Two_Factor();
		$two_factor_users = array();
		$users            = get_users();

		foreach ( $users as $user ) {
			$enabled          = $itsec_two_factor->is_user_using_two_factor( $user->ID );
			$override         = intval( get_user_option( 'itsec_two_factor_override', $user->ID ) ) === 1 ? true : false;
			$override_expires = intval( get_user_option( 'itsec_two_factor_override_expires', $user->ID ) );

			if ( $enabled == 'on' ) {

				$two_factor_users[$user->user_login] = array(
					'ID'               => $user->ID,
					'user_login'       => $user->user_login,
					'override'         => $override,
					'override_expires' => $override_expires,
				);

			}

		}

		return $two_factor_users;

	}
コード例 #25
0
 public function render($post)
 {
     $issue = new BuggyPress_Issue($post->ID);
     $users = get_users();
     $assignee = $issue->get_assignee_id();
     include BuggyPress::plugin_path('views/admin/meta-box-assignee.php');
 }
コード例 #26
0
	function setUp() {
		parent::setUp();
		// keep track of users we create
		$this->_flush_roles();

		$this->orig_users = get_users();
	}
コード例 #27
0
ファイル: chkadmin.php プロジェクト: healthcommcore/osnap
 public function process($ip, &$stats = array(), &$options = array(), &$post = array())
 {
     $login = $post['author'];
     // sticks login name into author
     $pwd = $post['pwd'];
     if (stripos($login, 'admin') === false) {
         return false;
     }
     // no users or authors named admin
     // do a look up to see if there is an author named admin.
     if (!function_exists('get_users')) {
         return false;
     }
     // non-wp?
     $blogusers = get_users();
     if (empty($blogusers)) {
         return false;
     }
     foreach ($blogusers as $u) {
         if ($u->user_login == $login) {
             return false;
         }
         // false alarm - really is a person admin
     }
     // this may cause problems when a legitimate new user wants to include the string admin in their user name.
     return "Admin login/registration attempt: {$login}";
 }
コード例 #28
0
ファイル: username.php プロジェクト: ksan5835/rankproperties
function wppb_check_username_value($message, $field, $request_data, $form_location)
{
    global $wpdb;
    if ($field['required'] == 'Yes') {
        if (isset($request_data['username']) && trim($request_data['username']) == '' || $form_location == 'register' && !isset($request_data['username'])) {
            return wppb_required_field_error($field["field-title"]);
        }
    }
    if (!empty($request_data['username'])) {
        if ($form_location == 'register') {
            $search_by_user_login = get_users('search=' . $request_data['username']);
        }
        if (!empty($search_by_user_login)) {
            return __('This username already exists.', 'profile-builder') . '<br/>' . __('Please try a different one!', 'profile-builder');
        }
        if (!validate_username($request_data['username'])) {
            return __('This username is invalid because it uses illegal characters.', 'profile-builder') . '<br/>' . __('Please enter a valid username.', 'profile-builder');
        }
        $wppb_generalSettings = get_option('wppb_general_settings');
        if ($wppb_generalSettings['emailConfirmation'] == 'yes') {
            if (is_multisite() && $request_data['username'] != preg_replace('/\\s+/', '', $request_data['username'])) {
                return __('This username is invalid because it uses illegal characters.', 'profile-builder') . '<br/>' . __('Please enter a valid username.', 'profile-builder');
            }
            $userSignup = $wpdb->get_results($wpdb->prepare("SELECT * FROM " . $wpdb->prefix . "signups WHERE user_login = %s", $request_data['username']));
            if (!empty($userSignup)) {
                return __('This username is already reserved to be used soon.', 'profile-builder') . '<br/>' . __('Please try a different one!', 'profile-builder');
            }
        }
    }
    return $message;
}
コード例 #29
-1
 function create()
 {
     $types = array("course", "quiz", "qa", "dis", "user", "amt");
     $AdminCapabilities = array('edit_linkedcanvas?', 'read_linkedcanvas?', 'delete_linkedcanvas?', 'edit_linkedcanvas?s', 'edit_others_linkedcanvas?s', 'publish_linkedcanvas?s', 'read_private_linkedcanvas?s', 'delete_linkedcanvas?s', 'delete_private_linkedcanvas?s', 'delete_published_linkedcanvas?s', 'delete_others_linkedcanvas?s', 'edit_private_linkedcanvas?s', 'edit_published_linkedcanvas?s', 'edit_linkedcanvas?s');
     $AuthorCapabilities = array('edit_linkedcanvas?', 'read_linkedcanvas?', 'delete_linkedcanvas?', 'edit_linkedcanvas?s', 'publish_linkedcanvas?s', 'read_private_linkedcanvas?s', 'delete_linkedcanvas?s', 'delete_private_linkedcanvas?s', 'delete_published_linkedcanvas?s', 'edit_private_linkedcanvas?s', 'edit_published_linkedcanvas?s', 'edit_linkedcanvas?s');
     $get_users = get_users();
     foreach ($get_users as $user) {
         if (in_array("administrator", $user->roles)) {
             $user = new WP_User($user->data->ID);
             foreach ($AdminCapabilities as $capability) {
                 foreach ($types as $type) {
                     $user->add_cap(str_replace("?", $type, $capability));
                 }
             }
         }
         if (in_array("editor", $user->roles)) {
             $user = new WP_User($user->data->ID);
             foreach ($AuthorCapabilities as $capability) {
                 foreach ($types as $type) {
                     $user->add_cap(str_replace("?", $type, $capability));
                 }
             }
         }
     }
 }
コード例 #30
-1
 function widget()
 {
     // Check if obj exists in cache
     $users = wp_cache_get('active_users');
     if ($users == false) {
         // Generate the query
         $users = get_users(array('role' => 'student'));
         // Cache the results
         wp_cache_set('active_users', $users, '', 300);
     }
     //$users = get_users( array( 'role' => 'student' ) );
     $users_for_counts = array();
     foreach ($users as $user) {
         $users_for_counts[] = $user->ID;
     }
     // Check if obj exists in cache
     $counts = wp_cache_get('user_count');
     if ($counts == false) {
         // Generate the obj
         $counts = count_many_users_posts($users_for_counts);
         // Cache the results
         wp_cache_set('user_count', $counts, '', 300);
     }
     arsort($counts);
     $counts = array_slice($counts, 0, 5, true);
     echo 'There are currently <strong>' . intval(count($users)) . '</strong> students with HS Insider accounts.';
     echo '<p><strong>Most-active students:</strong></p><ul>';
     foreach ($counts as $user_id => $count) {
         echo '<li><a href="' . esc_url(get_author_posts_url($user_id)) . '" target=_blank>' . esc_html(get_the_author_meta('display_name', $user_id)) . '</a>: (<strong>' . intval($count) . '</strong>)</li>';
     }
     echo '</ul>';
 }