コード例 #1
0
/**
 * Filter our user count to take into account spam members.
 * @param string $count Total active users.
 *
 * @return mixed|null|string
 */
function bp_registration_options_remove_moderated_count($count)
{
    $pending_count = bp_registration_get_pending_user_count();
    if (0 == $pending_count) {
        return $count;
    }
    global $wpdb;
    $total_count = get_transient('bpro_total_user_count');
    if (false === $total_count) {
        $status_sql = "user_status = 0";
        if (is_multisite()) {
            $status_sql = "spam = 0 AND deleted = 0 AND user_status = 0";
        }
        $total_count = $wpdb->get_var("SELECT COUNT(ID) FROM {$wpdb->users} WHERE {$status_sql}");
        set_transient('bpro_total_user_count', $total_count, HOUR_IN_SECONDS);
    }
    $final_count = $total_count - $pending_count;
    return $final_count > 0 ? $final_count : $count;
}
コード例 #2
0
/**
 * Options page for managing pending members.
 *
 * @since  unknown
 *
 * @return string  HTML page output
 */
function bp_registration_options_member_requests()
{
    /**/
    ?>

	<div class="wrap">
		<?php 
    bp_registration_options_tab_menu('requests');
    $member_requests = bp_registration_get_pending_user_count();
    if ($member_requests > 0) {
        ?>

			<form method="POST" name="bprwg">
			<?php 
        do_action('bpro_hook_before_pending_member_list');
        wp_nonce_field('bp_reg_options_check');
        ?>

			<p><?php 
        _e('Please approve or deny the following new members:', 'bp-registration-options');
        ?>
</p>

			<table class="widefat">
			<thead>
				<tr>
					<th id="cb" class="manage-column column-cb check-column" scope="col">
						<input type="checkbox" id="bp_checkall_top" name="checkall" />
					</th>
					<th><?php 
        _e('Photo', 'bp-registration-options');
        ?>
</th>
					<th><?php 
        _e('Name', 'bp-registration-options');
        ?>
</th>
					<th><?php 
        _e('Email', 'bp-registration-options');
        ?>
</th>
					<th><?php 
        _e('Created', 'bp-registration-options');
        ?>
</th>
					<th><?php 
        _e('Additional Data', 'bp-registration-options');
        ?>
</th>
				</tr>
			</thead>
			<?php 
        $odd = true;
        //Get paged value, determine total pages, and calculate start_from value for offset.
        $page = isset($_GET['p']) ? $_GET['p'] : 1;
        $total_pages = ceil($member_requests / 20);
        //TODO: Test pagination
        $start_from = ($page - 1) * 20;
        $pending_users = bp_registration_get_pending_users($start_from);
        foreach ($pending_users as $pending) {
            if (class_exists('BP_Core_User')) {
                $user = new BP_Core_User($pending->user_id);
            }
            $user_data = get_userdata($pending->user_id);
            $userip = trim(get_user_meta($pending->user_id, '_bprwg_ip_address', true));
            if ($odd) {
                ?>
					<tr class="alternate">
					<?php 
                $odd = false;
            } else {
                ?>
					<tr>
					<?php 
                $odd = true;
            }
            ?>
					<th class="check-column" scope="row">
						<input type="checkbox" class="bpro_checkbox" id="bp_member_check_<?php 
            echo $pending->user_id;
            ?>
" name="bp_member_check[]" value="<?php 
            echo $pending->user_id;
            ?>
"  />
					</th>
					<td>
						<?php 
            if (isset($user)) {
                ?>
							<a target="_blank" href="<?php 
                echo $user->user_url;
                ?>
">
								<?php 
                echo $user->avatar_mini;
                ?>
							</a>
						<?php 
            }
            ?>
					</td>
					<td>
						<?php 
            if (isset($user)) {
                ?>
							<strong><a target="_blank" href="<?php 
                echo $user->user_url;
                ?>
">
								<?php 
                echo $user->fullname;
                ?>
							</a></strong>
						<?php 
            } else {
                echo $user_data->user_login;
            }
            ?>
					</td>
					<td>
						<a href="mailto:<?php 
            echo $user_data->data->user_email;
            ?>
">
							<?php 
            echo $user_data->data->user_email;
            ?>
						</a>
					</td>
					<td>
						<?php 
            echo $user_data->data->user_registered;
            ?>
					</td>
					<td>
						<div class="alignleft">
							<img height="50" src="http://api.hostip.info/flag.php?ip=<?php 
            echo $userip;
            ?>
" / >
						</div>
						<div class="alignright">
							<?php 
            $response = wp_remote_get('http://api.hostip.info/get_html.php?ip=' . $userip);
            if (!is_wp_error($response)) {
                $data = $response['body'];
                $data = str_replace('City:', '<br>' . __('City:', 'bp-registration-options'), $data);
                $data = str_replace('IP:', '<br>' . __('IP:', 'bp-registration-options'), $data);
                echo $data;
            } else {
                echo $userip;
            }
            ?>
						</div>
					</td>
				</tr>
			<?php 
        }
        ?>
			<tfoot>
				<tr>
					<th class="manage-column column-cb check-column" scope="col"><input type="checkbox" id="bp_checkall_bottom" name="checkall" /></th>
					<th><?php 
        _e('Photo', 'bp-registration-options');
        ?>
</th>
					<th><?php 
        _e('Name', 'bp-registration-options');
        ?>
</th>
					<th><?php 
        _e('Email', 'bp-registration-options');
        ?>
</th>
					<th><?php 
        _e('Created', 'bp-registration-options');
        ?>
</th>
					<th><?php 
        _e('Additional Data', 'bp-registration-options');
        ?>
</th>
				</tr>
			</tfoot>
			</table>

			<p><input type="submit" class="button button-primary" name="moderate" value="<?php 
        esc_attr_e('Approve', 'bp-registration-options');
        ?>
" id="bpro_approve" />
			<input type="submit" class="button button-secondary" name="moderate" value="<?php 
        esc_attr_e('Deny', 'bp-registration-options');
        ?>
" id="bpro_deny" />
			<input type="submit" class="button button-secondary" name="moderate" disabled value="<?php 
        esc_attr_e('Ban', 'bp-registration-options');
        ?>
" id="bpro_ban" /></p>

			<?php 
        if ($total_pages > 1) {
            $current = !empty($_GET['p']) ? $_GET['p'] : 1;
            echo '<p>';
            for ($i = 1; $i <= $total_pages; $i++) {
                if ($i == $current) {
                    printf('<a class="bpro_current wp-ui-highlight" href="%s">%s</a>', esc_url(add_query_arg('p', $i)), $i);
                } else {
                    printf('<a href="%s">%s</a>', esc_url(add_query_arg('p', $i)), $i);
                }
            }
            echo '</p>';
        }
        do_action('bpro_hook_after_pending_member_list');
        ?>

			</form>

		<?php 
    } else {
        echo '<p><strong>' . __('No new members to approve.', 'bp-registration-options') . '</strong></p>';
    }
    ?>
	</div> <!--End Wrap-->

	<?php 
    bp_registration_options_admin_footer();
}