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


PHP bp_members函数代码示例

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


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

示例1: widget

 /** @see WP_Widget::widget -- do not rename this */
 function widget($args, $instance)
 {
     extract($args);
     //Our variables from the widget settings.
     $title = apply_filters('widget_title', $instance['title']);
     $num = $instance['number'];
     $activity = $instance['activity'];
     $messages = $instance['messages'];
     $friends = $instance['friends'];
     if (!is_numeric($num)) {
         $num = 5;
     }
     $user_id = bp_loggedin_user_id();
     $width = $instance['width'];
     echo '<div class="' . $width . '"><div class="dash-widget">' . $before_widget;
     echo '<div id="vibe-tabs-student-activity" class="tabs tabbable">
           <ul class="nav nav-tabs clearfix">';
     if (isset($messages) && $messages && function_exists('messages_get_unread_count')) {
         echo '<li><a href="#tab-messages" data-toggle="tab"><i class="icon-bubble-talk-1"></i>' . messages_get_unread_count($user_id) . '</a></li>';
     }
     if (isset($friends) && $friends) {
         $searchArgs = array('type' => 'online', 'page' => 1, 'per_page' => $num, 'user_id' => $user_id);
         if (bp_has_members($searchArgs)) {
             while (bp_members()) {
                 bp_the_member();
                 $user_friends[] = array('avatar' => bp_get_member_avatar(), 'name' => bp_get_member_name(), 'last_active' => bp_get_member_last_active());
             }
         }
         if (!is_array($user_friends)) {
             $user_friends = array();
         }
         echo '<li><a href="#tab-friends" data-toggle="tab"><i class="icon-myspace-alt"></i>' . count($user_friends) . '</a></li>';
     }
     if (isset($activity) && $activity) {
         echo '<li><a href="#tab-activity" data-toggle="tab"><i class="icon-atom"></i>&nbsp;</a></li>';
     }
     echo '</ul><div class="tab-content">';
     // Display the widget title
     global $wpdb, $bp;
     if (isset($messages) && $messages) {
         echo '<div id="tab-messages" class="tab-pane">
   <h4>' . __('Unread Messages', 'wplms-dashboard') . '</h4>';
         $message_args = array('user_id' => $user_id, 'box' => 'inbox', 'type' => 'unread', 'max' => $num);
         if (bp_has_message_threads($message_args)) {
             echo '<ul class="dash-unread-messages">';
             while (bp_message_threads()) {
                 bp_message_thread();
                 echo '<li>' . bp_get_message_thread_avatar() . '<a href="' . bp_get_message_thread_view_link() . '">' . bp_get_message_thread_subject() . '<span>' . bp_get_message_thread_from() . '</span></a></li>';
             }
             echo '</ul>';
         } else {
             echo '<div class="message error">' . __('No messages found', 'wplms-dashboard') . '</div>';
         }
         echo '</div>';
     }
     if (isset($friends) && $friends) {
         echo '<div id="tab-friends" class="tab-pane">
   <h4>' . __('Friends Online', 'wplms-dashboard') . '</h4>';
         if (count($user_friends)) {
             echo '<ul class="dash-user-friends">';
             foreach ($user_friends as $user_friend) {
                 echo '<li>' . $user_friend['avatar'] . ' ' . $user_friend['name'] . '<span>' . $user_friend['last_active'] . '</span></li>';
             }
             echo '</ul>';
         } else {
             echo '<div class="message error">' . __('No friends online', 'wplms-dashboard') . '</div>';
         }
         echo '</div>';
     }
     if (isset($activity) && $activity) {
         $activities = apply_filters('wplms_dashboard_activity', $wpdb->get_results($wpdb->prepare("\n\t\t\tSELECT *\n\t\t    FROM {$bp->activity->table_name} AS activity\n\t\t    WHERE \tactivity.user_id IN (%d)\n\t\t    AND     (activity.action != '' OR activity.action IS NOT NULL)\n\t\t    ORDER BY activity.date_recorded DESC\n\t\t    LIMIT 0,{$num}\n\t\t", $user_id)));
         echo '<div id="tab-activity" class="tab-pane student_activity">
       <h4>' . __('Recent Activity', 'wplms-dashboard') . '</h4>';
         if (isset($activities) && is_array($activities)) {
             echo '<ul class="dash-activities">';
             foreach ($activities as $activity) {
                 if (isset($activity->action) && $activity->action != '') {
                     $time = tofriendlytime(time() - strtotime($activity->date_recorded));
                     echo '<li class="' . $activity->component . ' ' . $activity->type . '">
   						<div class="dash-activity">
   							<span class="dash-activity-time">' . $time . ' ' . __('AGO', 'wplms-dashboard') . '</span>
   								<strong>' . $activity->action . '</strong>
   						</div>
   					  </li>';
                 }
             }
             echo '</ul>';
         } else {
             echo '<div class="message error">' . __('No activity found', 'wplms-dashboard') . '</div>';
         }
         echo '</div>';
     }
     echo '</div></div>' . $after_widget . '</div></div>';
 }
开发者ID:nikitansk,项目名称:devschool,代码行数:95,代码来源:activity_widget.php

示例2: widget

    /**
     * Displays the widget.
     */
    function widget($args, $instance)
    {
        // do not do anything if user isn't logged in
        if (!is_user_logged_in()) {
            return;
        }
        if (empty($instance['max_users'])) {
            $instance['max_users'] = 16;
        }
        // logged-in user isn't following anyone, so stop!
        if (!($following = bp_get_following_ids(array('user_id' => bp_loggedin_user_id())))) {
            return false;
        }
        // show the users the logged-in user is following
        if (bp_has_members(array('include' => $following, 'max' => $instance['max_users'], 'populate_extras' => false))) {
            do_action('bp_before_following_widget');
            echo $args['before_widget'];
            echo $args['before_title'] . $instance['title'] . $args['after_title'];
            ?>

			<div class="avatar-block">
				<?php 
            while (bp_members()) {
                bp_the_member();
                ?>
					<div class="item-avatar">
						<a href="<?php 
                bp_member_permalink();
                ?>
" title="<?php 
                bp_member_name();
                ?>
"><?php 
                bp_member_avatar();
                ?>
</a>
					</div>
				<?php 
            }
            ?>
			</div>

			<?php 
            echo $args['after_widget'];
            ?>

			<?php 
            do_action('bp_after_following_widget');
            ?>

	<?php 
        }
    }
开发者ID:wesavetheworld,项目名称:buddypress-followers,代码行数:56,代码来源:widgets.php

示例3: bpChat_displayGroupChatAdmin

function bpChat_displayGroupChatAdmin()
{
    global $bp;
    global $members_template;
    ?>
<script>
    jQuery(document).ready(function() {
            jQuery('div#item-nav').before("<div id='bp-group-chat-online'><p id='bp-group-chat-online-text'><?php 
    _e("Admin is offline", "bp-chat");
    ?>
</p></div>");
<?php 
    if (function_exists('bp_has_members')) {
        if (bp_has_members('user_id=0&type=online&per_page=' . $instance['max_members'] . '&max=' . $instance['max_members'] . '&populate_extras=0')) {
            while (bp_members()) {
                bp_the_member();
                if ($members_template->member->id == $bp->groups->current_group->admins[0]->user_id && ($bp->groups->current_group->admins[0]->is_admin == 1 || $bp->groups->current_group->admins[0]->is_mod == 1)) {
                    ?>
		jQuery('div#bp-group-chat-online').html("<p id='bp-group-chat-online-text'><?php 
                    _e("Admin is online", "bp-chat");
                    ?>
</p>");
		if ( (int)get_site_option( 'bp-chat-setting-disable-shoutbox-chat' ) == 0 ) {
			jQuery('#shoutboxwrapper').show('slow');
		}
<?php 
                }
            }
        } else {
            ?>
            jQuery('div#bp-group-chat-online').html("<p id='bp-group-chat-online-text'><?php 
            _e("There are no admin users currently online", "bp-chat");
            ?>
</p>");
<?php 
        }
    }
    ?>
        jQuery('div#bp-group-chat-online').append("<?php 
    echo "<br />";
    ?>
");
    });
    </script>
<?php 
}
开发者ID:adisonc,项目名称:MaineLearning,代码行数:46,代码来源:bp-chat-groups.php

示例4: test_should_contain_member_type_classes

 /**
  * @ticket BP6996
  */
 public function test_should_contain_member_type_classes()
 {
     buddypress()->members->types = array();
     bp_register_member_type('foo');
     bp_register_member_type('bar');
     $u = $this->factory->user->create();
     bp_set_member_type($u, 'bar');
     if (bp_has_members(array('include' => array($u)))) {
         while (bp_members()) {
             bp_the_member();
             $found = bp_get_member_class();
         }
     }
     global $members_template;
     unset($members_template);
     buddypress()->members->types = array();
     $this->assertContains('member-type-bar', $found);
     $this->assertNotContains('member-type-foo', $found);
 }
开发者ID:CompositeUK,项目名称:clone.BuddyPress,代码行数:22,代码来源:bpGetMemberClass.php

示例5: widget

    /**
     * Display the Recently Active widget.
     *
     * @see WP_Widget::widget() for description of parameters.
     *
     * @param array $args Widget arguments.
     * @param array $instance Widget settings, as saved by the user.
     */
    function widget($args, $instance)
    {
        extract($args);
        $title = apply_filters('widget_title', $instance['title']);
        echo $before_widget;
        echo $before_title . $title . $after_title;
        $members_args = array('user_id' => 0, 'type' => 'active', 'per_page' => $instance['max_members'], 'max' => $instance['max_members'], 'populate_extras' => true, 'search_terms' => false);
        ?>

		<?php 
        if (bp_has_members($members_args)) {
            ?>
			<div class="avatar-block">
				<?php 
            while (bp_members()) {
                bp_the_member();
                ?>
					<div class="item-avatar">
						<a href="<?php 
                bp_member_permalink();
                ?>
" title="<?php 
                bp_member_name();
                ?>
"><?php 
                bp_member_avatar();
                ?>
</a>
					</div>
				<?php 
            }
            ?>
			</div>
		<?php 
        } else {
            ?>

			<div class="widget-error">
				<?php 
            _e('There are no recently active members', 'buddypress');
            ?>
			</div>

		<?php 
        }
        ?>

		<?php 
        echo $after_widget;
        ?>
	<?php 
    }
开发者ID:eresyyl,项目名称:mk,代码行数:60,代码来源:bp-core-widgets.php

示例6: test_bp_get_member_profile_data_inside_loop

 /**
  * @group bp_get_member_profile_data
  */
 public function test_bp_get_member_profile_data_inside_loop()
 {
     $u = $this->factory->user->create();
     $g = $this->factory->xprofile_group->create();
     $f = $this->factory->xprofile_field->create(array('field_group_id' => $g, 'name' => 'Neato'));
     xprofile_set_field_data($f, $u, 'foo');
     if (bp_has_members()) {
         while (bp_members()) {
             bp_the_member();
             $found = bp_get_member_profile_data(array('user_id' => $u, 'field' => 'Neato'));
         }
     }
     // Cleanup
     unset($GLOBALS['members_template']);
     $this->assertSame('foo', $found);
 }
开发者ID:dcavins,项目名称:buddypress-svn,代码行数:19,代码来源:functions.php

示例7: generate_html

 protected function generate_html($template_type = '')
 {
     $group_ids = array();
     foreach ($this->search_results['items'] as $item_id => $item) {
         $group_ids[] = $item_id;
     }
     //now we have all the posts
     //lets do a groups loop
     if (bp_has_members(array('include' => $group_ids, 'per_page' => count($group_ids)))) {
         while (bp_members()) {
             bp_the_member();
             $result_item = array('id' => bp_get_member_user_id(), 'type' => $this->type, 'title' => bp_get_member_name(), 'html' => buddyboss_global_search_buffer_template_part('loop/member', $template_type, false));
             $this->search_results['items'][bp_get_member_user_id()] = $result_item;
         }
     }
 }
开发者ID:tvolmari,项目名称:hammydowns,代码行数:16,代码来源:class.BBoss_Global_Search_Members.php

示例8: list_friends

        /**
         * Outputs the list of friends (active or online)
         * 
         * @package BP_Show_Friends_Widget
         * @since    2.0
         * 
         * @uses bp_is_user() to check we're on a user's profile
         * @uses bp_displayed_user_id() to get displayed user id
         * @uses bp_loggedin_user_id() to get loggedin user id
         * @uses Widget->get_settings() to get the instance of the widget
         * @uses the Members loop
         */
        public function list_friends($limit = 0, $size = 0)
        {
            $user_id = bp_is_user() ? bp_displayed_user_id() : bp_loggedin_user_id();
            if (empty($limit) || empty($size)) {
                $widget_settings = $this->get_settings();
                $number = intval($_POST['bpsf_number']);
                $limit = !empty($widget_settings[$number]['per_page']) ? $widget_settings[$number]['per_page'] : 5;
                $size = !empty($widget_settings[$number]['size']) ? $widget_settings[$number]['size'] : 50;
            }
            // plugins or themes can now order the friends differently !
            $args = apply_filters('bp_show_friends_args', array('user_id' => $user_id, 'type' => 'active', 'per_page' => $limit, 'max' => $limit, 'populate_extra' => 0));
            $fallback_message = '<p>' . __('No friends!', 'bp-show-friends') . '</p>';
            if (!empty($_POST['bpsf_type'])) {
                $args['type'] = $_POST['bpsf_type'];
                if ('online' == $args['type']) {
                    $fallback_message = '<p>' . __('No online friends!', 'bp-show-friends') . '</p>';
                }
            }
            $avatar_args = apply_filters('bp_show_friends_avatar_args', array('type' => 'full', 'width' => $size, 'height' => $size, 'class' => 'avatar bp-show-friends'));
            ?>

		<?php 
            if (empty($_POST['bpsf_type'])) {
                ?>
			<div class="friends-container">
		<?php 
            }
            ?>

		    <?php 
            if (bp_has_members($args)) {
                ?>
		    	<ul class="bpsf-members">
			      <?php 
                while (bp_members()) {
                    bp_the_member();
                    ?>

			      	<li class="bpsf-member">
				        <div class="item-avatar">
				          	<a href="<?php 
                    bp_member_permalink();
                    ?>
" title="<?php 
                    bp_member_name();
                    ?>
">
				          		<?php 
                    bp_member_avatar($avatar_args);
                    ?>
				          	</a>
				        </div>
				        <?php 
                    do_action('bp_show_friends_after_friend_avatar', bp_get_member_user_id());
                    ?>
				    </li>

			      <?php 
                }
                ?>
			     </ul>

		    <?php 
            } else {
                echo $fallback_message;
            }
            if (empty($_POST['bpsf_type'])) {
                ?>
			</div>
		    <br style="clear:both"/>
		<?php 
            } else {
                exit;
            }
        }
开发者ID:socialray,项目名称:surfied-2-0,代码行数:87,代码来源:bp-show-friends.php

示例9: friends_get_friends_invite_list

/**
 * Get a list of friends that a user can invite into this group.
 *
 * Excludes friends that are already in the group, and banned friends if the
 * user is not a group admin.
 *
 * @since 1.0.0
 *
 * @param int $user_id  User ID whose friends to see can be invited. Default:
 *                      ID of the logged-in user.
 * @param int $group_id Group to check possible invitations against.
 * @return mixed False if no friends, array of users if friends.
 */
function friends_get_friends_invite_list($user_id = 0, $group_id = 0)
{
    // Default to logged in user id.
    if (empty($user_id)) {
        $user_id = bp_loggedin_user_id();
    }
    // Only group admins can invited previously banned users.
    $user_is_admin = (bool) groups_is_user_admin($user_id, $group_id);
    // Assume no friends.
    $friends = array();
    /**
     * Filters default arguments for list of friends a user can invite into this group.
     *
     * @since 1.5.4
     *
     * @param array $value Array of default parameters for invite list.
     */
    $args = apply_filters('bp_friends_pre_get_invite_list', array('user_id' => $user_id, 'type' => 'alphabetical', 'per_page' => 0));
    // User has friends.
    if (bp_has_members($args)) {
        /**
         * Loop through all friends and try to add them to the invitation list.
         *
         * Exclude friends that:
         *     1. are already members of the group
         *     2. are banned from this group if the current user is also not a
         *        group admin.
         */
        while (bp_members()) {
            // Load the member.
            bp_the_member();
            // Get the user ID of the friend.
            $friend_user_id = bp_get_member_user_id();
            // Skip friend if already in the group.
            if (groups_is_user_member($friend_user_id, $group_id)) {
                continue;
            }
            // Skip friend if not group admin and user banned from group.
            if (false === $user_is_admin && groups_is_user_banned($friend_user_id, $group_id)) {
                continue;
            }
            // Friend is safe, so add it to the array of possible friends.
            $friends[] = array('id' => $friend_user_id, 'full_name' => bp_get_member_name());
        }
    }
    // If no friends, explicitly set to false.
    if (empty($friends)) {
        $friends = false;
    }
    /**
     * Filters the list of potential friends that can be invited to this group.
     *
     * @since 1.5.4
     *
     * @param array|bool $friends  Array friends available to invite or false for no friends.
     * @param int        $user_id  ID of the user checked for who they can invite.
     * @param int        $group_id ID of the group being checked on.
     */
    return apply_filters('bp_friends_get_invite_list', $friends, $user_id, $group_id);
}
开发者ID:CompositeUK,项目名称:clone.BuddyPress,代码行数:73,代码来源:bp-friends-functions.php

示例10: bp_core_ajax_widget_friends

/**
 * Process AJAX pagination or filtering for the Friends widget.
 *
 * @since 1.9.0
 */
function bp_core_ajax_widget_friends()
{
    check_ajax_referer('bp_core_widget_friends');
    switch ($_POST['filter']) {
        case 'newest-friends':
            $type = 'newest';
            break;
        case 'recently-active-friends':
            $type = 'active';
            break;
        case 'popular-friends':
            $type = 'popular';
            break;
    }
    $members_args = array('user_id' => bp_displayed_user_id(), 'type' => $type, 'max' => absint($_POST['max-friends']), 'populate_extras' => 1);
    if (bp_has_members($members_args)) {
        ?>
		<?php 
        echo '0[[SPLIT]]';
        // Return valid result. TODO: remove this.
        ?>
		<?php 
        while (bp_members()) {
            bp_the_member();
            ?>
			<li class="vcard">
				<div class="item-avatar">
					<a href="<?php 
            bp_member_permalink();
            ?>
"><?php 
            bp_member_avatar();
            ?>
</a>
				</div>

				<div class="item">
					<div class="item-title fn"><a href="<?php 
            bp_member_permalink();
            ?>
" title="<?php 
            bp_member_name();
            ?>
"><?php 
            bp_member_name();
            ?>
</a></div>
					<?php 
            if ('active' == $type) {
                ?>
						<div class="item-meta"><span class="activity"><?php 
                bp_member_last_active();
                ?>
</span></div>
					<?php 
            } elseif ('newest' == $type) {
                ?>
						<div class="item-meta"><span class="activity"><?php 
                bp_member_registered();
                ?>
</span></div>
					<?php 
            } elseif (bp_is_active('friends')) {
                ?>
						<div class="item-meta"><span class="activity"><?php 
                bp_member_total_friend_count();
                ?>
</span></div>
					<?php 
            }
            ?>
				</div>
			</li>
		<?php 
        }
        ?>

	<?php 
    } else {
        ?>
		<?php 
        echo "-1[[SPLIT]]<li>";
        ?>
		<?php 
        _e('There were no members found, please try another filter.', 'buddypress');
        ?>
		<?php 
        echo "</li>";
        ?>
	<?php 
    }
}
开发者ID:dcavins,项目名称:buddypress-svn,代码行数:97,代码来源:bp-friends-widgets.php

示例11: test_friends_check_friendship_status_in_members_loop

 /**
  * @group friends_check_friendship_status
  */
 public function test_friends_check_friendship_status_in_members_loop()
 {
     $now = time();
     $u1 = $this->factory->user->create(array('last_activity' => date('Y-m-d H:i:s', $now)));
     $u2 = $this->factory->user->create(array('last_activity' => date('Y-m-d H:i:s', $now - 100)));
     $u3 = $this->factory->user->create(array('last_activity' => date('Y-m-d H:i:s', $now - 200)));
     $u4 = $this->factory->user->create(array('last_activity' => date('Y-m-d H:i:s', $now - 300)));
     $u5 = $this->factory->user->create(array('last_activity' => date('Y-m-d H:i:s', $now - 400)));
     friends_add_friend($u1, $u2, true);
     friends_add_friend($u1, $u3, false);
     friends_add_friend($u4, $u1, false);
     $old_user = get_current_user_id();
     $this->set_current_user($u1);
     $found = array();
     if (bp_has_members()) {
         while (bp_members()) {
             bp_the_member();
             $found[bp_get_member_user_id()] = friends_check_friendship_status($u1, bp_get_member_user_id());
         }
     }
     $expected = array($u1 => 'not_friends', $u2 => 'is_friend', $u3 => 'pending', $u4 => 'awaiting_response', $u5 => 'not_friends');
     $this->assertSame($expected, $found);
     // clean up
     $GLOBALS['members_template'] = null;
     $this->set_current_user($old_user);
 }
开发者ID:JeroenNouws,项目名称:BuddyPress,代码行数:29,代码来源:functions.php

示例12: results

 /**
  * Display results
  */
 public function results()
 {
     //Show/hide members with no location in the results. Default set to false
     $this->show_non_located_users = apply_filters('show_users_without_location', false, $this->form);
     //prevent BuddyPress from using its own "paged" value for the current page
     if (!empty($_REQUEST['upage'])) {
         unset($_REQUEST['upage']);
     }
     /*
     $xp_ids = array();
     
     //query the xprofile fields. This is done in a saperate function
     if ( apply_filters( 'gmw_fl_do_xprofile_query', true ) ) {
         
         $xprofile_users = gmw_fl_query_xprofile_fields( $this->form ,$_GET );
     
         //if fields entered but no users returned abort the query
         if ( $xprofile_users['status'] == 'no_ids_found' ) {
     
             $xp_ids = 0;
     
         //if users returned. add them to query
         } elseif ( $xprofile_users['status'] == 'ids_found' ) {
     
             $xp_ids = $xprofile_users['ids'];
         }
     }
     */
     //query args
     $this->form['query_args'] = apply_filters('gmw_fl_search_query_args', array('type' => 'distance', 'per_page' => $this->form['get_per_page'], 'page' => $this->form['paged']), $this->form);
     //modify the form values before query
     $this->form = apply_filters('gmw_fl_form_before_members_query', $this->form, $this->settings);
     $this->form = apply_filters("gmw_fl_form_before_members_query_{$this->form['ID']}", $this->form, $this->settings);
     //modify BP users query
     add_action('bp_pre_user_query', array($this, 'gmwBpQuery'));
     //modify WP User query
     add_action('pre_user_query', array($this, 'gmwWpQuery'));
     //enqueue stylesheet and get results template file
     $results_template = $this->search_results();
     if (bp_has_members($this->form['query_args'])) {
         global $members_template;
         $members_template = apply_filters('gmw_fl_members_before_members_loop', $members_template, $this->form, $this->settings);
         //setup member count
         $this->form['member_count'] = $this->form['paged'] == 1 ? 1 : $this->form['get_per_page'] * ($this->form['paged'] - 1) + 1;
         $this->form['results'] = $members_template->members;
         $this->form['total_results'] = $members_template->total_member_count;
         $this->form['max_pages'] = $this->form['total_results'] / $this->form['get_per_page'];
         echo '<div id="buddypress">';
         //load results template file to display list of members
         if (isset($this->form['search_results']['display_members']) && !$this->form['in_widget']) {
             add_action('gmw_search_results_loop_item_start', array($this, 'modify_member'), 10);
             $gmw = $this->form;
             include $results_template;
             /*
              * if we do not display list of members we still need to have a loop
              * and add some information to each members in order to be able to
              * display it on the map
              */
         } elseif ($this->form['search_results']['display_map'] != 'na') {
             while (bp_members()) {
                 bp_the_member();
                 self::modify_member();
             }
         }
         echo '</div>';
     }
     remove_action('bp_pre_user_query', array($this, 'gmwBpQuery'));
     remove_action('pre_user_query', array($this, 'gmwWpQuery'));
 }
开发者ID:poweronio,项目名称:mbsite,代码行数:72,代码来源:gmw-fl-search-query-class.php

示例13: friends_get_friends_invite_list

/**
 * Get a list of friends that a user can invite into this group.
 *
 * Excludes friends that are already in the group, and banned friends if the
 * user is not a group admin.
 *
 * @since BuddyPress (1.0.0)
 *
 * @param int $user_id User ID whose friends to see can be invited. Default:
 *        ID of the logged-in user.
 * @param int $group_id Group to check possible invitations against.
 * @return mixed False if no friends, array of users if friends.
 */
function friends_get_friends_invite_list($user_id = 0, $group_id = 0)
{
    // Default to logged in user id
    if (empty($user_id)) {
        $user_id = bp_loggedin_user_id();
    }
    // Only group admins can invited previously banned users
    $user_is_admin = (bool) groups_is_user_admin($user_id, $group_id);
    // Assume no friends
    $friends = array();
    // Default args
    $args = apply_filters('bp_friends_pre_get_invite_list', array('user_id' => $user_id, 'type' => 'alphabetical', 'per_page' => 0));
    // User has friends
    if (bp_has_members($args)) {
        /**
         * Loop through all friends and try to add them to the invitation list.
         *
         * Exclude friends that:
         *     1. are already members of the group
         *     2. are banned from this group if the current user is also not a
         *        group admin.
         */
        while (bp_members()) {
            // Load the member
            bp_the_member();
            // Get the user ID of the friend
            $friend_user_id = bp_get_member_user_id();
            // Skip friend if already in the group
            if (groups_is_user_member($friend_user_id, $group_id)) {
                continue;
            }
            // Skip friend if not group admin and user banned from group
            if (false === $user_is_admin && groups_is_user_banned($friend_user_id, $group_id)) {
                continue;
            }
            // Friend is safe, so add it to the array of possible friends
            $friends[] = array('id' => $friend_user_id, 'full_name' => bp_get_member_name());
        }
    }
    // If no friends, explicitly set to false
    if (empty($friends)) {
        $friends = false;
    }
    // Allow friends to be filtered
    return apply_filters('bp_friends_get_invite_list', $friends, $user_id, $group_id);
}
开发者ID:eresyyl,项目名称:mk,代码行数:59,代码来源:bp-friends-functions.php

示例14: widget

    /**
     * Display the Members widget.
     *
     * @see WP_Widget::widget() for description of parameters.
     *
     * @param array $args Widget arguments.
     * @param array $instance Widget settings, as saved by the user.
     */
    function widget($args, $instance)
    {
        extract($args);
        if (!$instance['member_default']) {
            $instance['member_default'] = 'active';
        }
        $title = apply_filters('widget_title', $instance['title']);
        echo $before_widget;
        $title = $instance['link_title'] ? '<a href="' . esc_url(trailingslashit(bp_get_root_domain() . '/' . bp_get_members_root_slug())) . '">' . $title . '</a>' : $title;
        echo $before_title . $title . $after_title;
        $members_args = array('user_id' => 0, 'type' => $instance['member_default'], 'per_page' => $instance['max_members'], 'max' => $instance['max_members'], 'populate_extras' => true, 'search_terms' => false);
        ?>

		<?php 
        if (bp_has_members($members_args)) {
            ?>
			<div class="item-options" id="members-list-options">
				<a href="<?php 
            bp_members_directory_permalink();
            ?>
" id="newest-members" <?php 
            if ($instance['member_default'] == 'newest') {
                ?>
class="selected"<?php 
            }
            ?>
><?php 
            _e('Newest', 'socialchef');
            ?>
</a>
				<a href="<?php 
            bp_members_directory_permalink();
            ?>
" id="recently-active-members" <?php 
            if ($instance['member_default'] == 'active') {
                ?>
class="selected"<?php 
            }
            ?>
><?php 
            _e('Active', 'socialchef');
            ?>
</a>
				<?php 
            if (bp_is_active('friends')) {
                ?>
				<a href="<?php 
                bp_members_directory_permalink();
                ?>
" id="popular-members" <?php 
                if ($instance['member_default'] == 'popular') {
                    ?>
class="selected"<?php 
                }
                ?>
><?php 
                _e('Popular', 'socialchef');
                ?>
</a>
				<?php 
            }
            ?>
			</div>

			<ul id="members-list" class="item-list">
				<?php 
            while (bp_members()) {
                bp_the_member();
                ?>
					<li class="vcard">
						<div class="item-avatar">
							<a role="member" href="<?php 
                bp_member_permalink();
                ?>
" title="<?php 
                bp_member_name();
                ?>
"><?php 
                bp_member_avatar();
                ?>
</a>
						</div>
					</li>

				<?php 
            }
            ?>
			</ul>
			<?php 
            wp_nonce_field('bp_core_widget_members', '_wpnonce-members');
            ?>
			<input type="hidden" name="members_widget_max" id="members_widget_max" value="<?php 
//.........这里部分代码省略.........
开发者ID:boutitinizar,项目名称:bati-men,代码行数:101,代码来源:widget_buddypress-members.php

示例15: save_event

 /**
  * Save or update a new event
  * @version 2.0
  */
 function save_event($post_id, $post = '')
 {
     // Don't do anything if it's not an event
     if ('event' != $post->post_type) {
         return;
     }
     // Verify the nonce before proceeding.
     if (!isset($_POST['event-details-box']) || !wp_verify_nonce($_POST['event-details-box'], basename(__FILE__))) {
         return $post_id;
     }
     /* -----------------------------------
     			SAVE EVENT TIME 
     		------------------------------------*/
     // Retrieve the event time
     $event_time = date('Y-m-d H:i:s', strtotime($_POST['event-time']));
     $prior_time = $post->post_date;
     // Update the post object
     $post->post_date = $event_time;
     remove_action('save_post', array($this, 'save_event'));
     wp_update_post($post);
     add_action('save_post', array($this, 'save_event'), 10, 2);
     /* -----------------------------------
     			SAVE META INFORMATION 
     		------------------------------------ */
     // Define the meta to look for
     $meta = array('event_duration' => $_POST['event-duration'], 'event_capacity' => $_POST['event-capacity'], 'event_rsvp' => $_POST['event-rsvp'], 'event_role' => $_POST['event-role']);
     // Loop through each meta, saving it to the database
     foreach ($meta as $meta_key => $new_meta_value) {
         // Get the meta value of the custom field key.
         $meta_value = get_post_meta($post_id, $meta_key, true);
         // If there is no new meta value but an old value exists, delete it.
         if (current_user_can('delete_post_meta', $post_id, $meta_key) && '' == $new_meta_value && $meta_value) {
             delete_post_meta($post_id, $meta_key, $meta_value);
         } elseif (current_user_can('add_post_meta', $post_id, $meta_key) && $new_meta_value && '' == $meta_value) {
             add_post_meta($post_id, $meta_key, $new_meta_value, true);
         } elseif (current_user_can('edit_post_meta', $post_id, $meta_key) && $new_meta_value && $new_meta_value != $meta_value) {
             update_post_meta($post_id, $meta_key, $new_meta_value);
         }
     }
     // Delete the RSVP meta if the date has changed
     if ($event_time != $prior_time) {
         delete_post_meta($post_id, 'event_rsvps');
     }
     /* -----------------------------------
     			BUDDYPRESS NOTIFICATION
     		------------------------------------ */
     // Get event data
     global $bp, $wpdb;
     if (!$user_id) {
         $user_id = $post->post_author;
     }
     // Figure out which calendars this event belongs to
     $calendars = wp_get_post_terms($post_id, 'calendar');
     $group_slugs = array();
     // For each calendar, check if it's a group calendar
     foreach ($calendars as $calendar) {
         if (is_group_calendar($calendar->term_id)) {
             $groups[] = $calendar;
         }
     }
     // If this event does not belong to a group, we can stop here
     if (empty($groups)) {
         return $post_id;
     }
     // Only register notifications for future or published events
     if (!in_array($post->post_status, array('publish', 'future'))) {
         return $post_id;
     }
     // Loop through each group, adding an activity entry for each one
     foreach ($groups as $group) {
         // Get the group data
         $group_id = groups_get_id($group->slug);
         $group_name = $group->name;
         // Configure the activity entry
         $post_permalink = get_permalink($post_id);
         $activity_action = sprintf('%1$s added the event %2$s to the %3$s.', bp_core_get_userlink($post->post_author), '<a href="' . $post_permalink . '">' . $post->post_title . '</a>', $group_name . ' <a href="' . SITEURL . '/calendar/' . $group->slug . '">group calendar</a>');
         $activity_content = $post->post_content;
         // Check for existing entry
         $activity_id = bp_activity_get_activity_id(array('user_id' => $user_id, 'component' => $bp->groups->id, 'type' => 'new_calendar_event', 'item_id' => $group_id, 'secondary_item_id' => $post_id));
         // Record the entry
         groups_record_activity(array('id' => $activity_id, 'user_id' => $user_id, 'action' => $activity_action, 'content' => $activity_content, 'primary_link' => $post_permalink, 'type' => 'new_calendar_event', 'item_id' => $group_id, 'secondary_item_id' => $post_id));
         // Update the group's last activity meta
         groups_update_groupmeta($group_id, 'last_activity', bp_core_current_time());
         // Maybe notify every group member
         if ($_POST['event-rsvp']) {
             if (bp_group_has_members($args = array('group_id' => $group_id, 'exclude_admins_mods' => false, 'per_page' => 99999))) {
                 while (bp_members()) {
                     bp_the_member();
                     // Remove any existing notifications ( $user_id, $item_id, $component_name, $component_action, $secondary_item_id = false )
                     bp_notifications_delete_notifications_by_item_id(bp_get_group_member_id(), $group_id, $bp->groups->id, 'new_calendar_event', $post_id);
                     // Send a notification ( itemid , groupid , component, action , secondary )
                     bp_notifications_add_notification(array('user_id' => bp_get_group_member_id(), 'item_id' => $group_id, 'secondary_item_id' => $post_id, 'component_name' => $bp->groups->id, 'component_action' => 'new_calendar_event'));
                 }
             }
         }
     }
//.........这里部分代码省略.........
开发者ID:tamriel-foundry,项目名称:apoc2,代码行数:101,代码来源:events.php


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