本文整理汇总了PHP中groups_total_groups_for_user函数的典型用法代码示例。如果您正苦于以下问题:PHP groups_total_groups_for_user函数的具体用法?PHP groups_total_groups_for_user怎么用?PHP groups_total_groups_for_user使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了groups_total_groups_for_user函数的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: test_should_return_integer_when_fetching_from_cache
/**
* @ticket BP6813
*/
public function test_should_return_integer_when_fetching_from_cache()
{
/*
* Put a string in the cache.
* In-memory cache will respect type, but persistent caching engines return all scalars as strings.
*/
wp_cache_set('bp_total_groups_for_user_123', '321', 'bp');
$this->assertInternalType('int', groups_total_groups_for_user(123));
}
示例2: bp_get_total_group_count_for_user
function bp_get_total_group_count_for_user($user_id = 0)
{
return apply_filters('bp_get_total_group_count_for_user', groups_total_groups_for_user($user_id), $user_id);
}
示例3: bp_get_total_group_count_for_user
/**
* Return the total number of groups a user belongs to.
*
* Filtered by `bp_core_number_format()` by default
*
* @since 1.0.0
*
* @param int $user_id User ID to get group membership count.
* @return string
*/
function bp_get_total_group_count_for_user($user_id = 0)
{
$count = groups_total_groups_for_user($user_id);
/**
* Filters the total number of groups a user belongs to.
*
* @since 1.2.0
*
* @param int $count Total number of groups for the user.
* @param int $user_id ID of the user being checked.
*/
return apply_filters('bp_get_total_group_count_for_user', $count, $user_id);
}
示例4: setup_nav
/**
* Set up component navigation.
*
* @since 1.5.0
*
* @see BP_Component::setup_nav() for a description of arguments.
*
* @param array $main_nav Optional. See BP_Component::setup_nav() for description.
* @param array $sub_nav Optional. See BP_Component::setup_nav() for description.
*/
public function setup_nav($main_nav = array(), $sub_nav = array())
{
// Determine user to use.
if (bp_displayed_user_domain()) {
$user_domain = bp_displayed_user_domain();
} elseif (bp_loggedin_user_domain()) {
$user_domain = bp_loggedin_user_domain();
} else {
$user_domain = false;
}
// Only grab count if we're on a user page.
if (bp_is_user()) {
$class = 0 === groups_total_groups_for_user(bp_displayed_user_id()) ? 'no-count' : 'count';
$nav_name = sprintf(_x('Groups %s', 'Group screen nav with counter', 'buddypress'), sprintf('<span class="%s">%s</span>', esc_attr($class), bp_get_total_group_count_for_user()));
} else {
$nav_name = _x('Groups', 'Group screen nav without counter', 'buddypress');
}
$slug = bp_get_groups_slug();
// Add 'Groups' to the main navigation.
$main_nav = array('name' => $nav_name, 'slug' => $slug, 'position' => 70, 'screen_function' => 'groups_screen_my_groups', 'default_subnav_slug' => 'my-groups', 'item_css_id' => $this->id);
if (!empty($user_domain)) {
$access = bp_core_can_edit_settings();
$groups_link = trailingslashit($user_domain . $slug);
// Add the My Groups nav item.
$sub_nav[] = array('name' => __('Memberships', 'buddypress'), 'slug' => 'my-groups', 'parent_url' => $groups_link, 'parent_slug' => $slug, 'screen_function' => 'groups_screen_my_groups', 'position' => 10, 'item_css_id' => 'groups-my-groups');
// Add the Group Invites nav item.
$sub_nav[] = array('name' => __('Invitations', 'buddypress'), 'slug' => 'invites', 'parent_url' => $groups_link, 'parent_slug' => $slug, 'screen_function' => 'groups_screen_group_invites', 'user_has_access' => $access, 'position' => 30);
parent::setup_nav($main_nav, $sub_nav);
}
if (bp_is_groups_component() && bp_is_single_item()) {
// Reset sub nav.
$sub_nav = array();
/*
* The top-level Groups item is called 'Memberships' for legacy reasons.
* It does not appear in the interface.
*/
bp_core_new_nav_item(array('name' => __('Memberships', 'buddypress'), 'slug' => $this->current_group->slug, 'position' => -1, 'screen_function' => 'groups_screen_group_home', 'default_subnav_slug' => $this->default_extension, 'item_css_id' => $this->id), 'groups');
$group_link = bp_get_group_permalink($this->current_group);
// Add the "Home" subnav item, as this will always be present.
$sub_nav[] = array('name' => _x('Home', 'Group screen navigation title', 'buddypress'), 'slug' => 'home', 'parent_url' => $group_link, 'parent_slug' => $this->current_group->slug, 'screen_function' => 'groups_screen_group_home', 'position' => 10, 'item_css_id' => 'home');
// If this is a private group, and the user is not a
// member and does not have an outstanding invitation,
// show a "Request Membership" nav item.
if (is_user_logged_in() && !$this->current_group->is_user_member && !groups_check_for_membership_request(bp_loggedin_user_id(), $this->current_group->id) && $this->current_group->status == 'private' && !groups_check_user_has_invite(bp_loggedin_user_id(), $this->current_group->id)) {
$sub_nav[] = array('name' => _x('Request Membership', 'Group screen nav', 'buddypress'), 'slug' => 'request-membership', 'parent_url' => $group_link, 'parent_slug' => $this->current_group->slug, 'screen_function' => 'groups_screen_group_request_membership', 'position' => 30);
}
// Forums are enabled and turned on.
if ($this->current_group->enable_forum && bp_is_active('forums')) {
$sub_nav[] = array('name' => _x('Forum', 'My Group screen nav', 'buddypress'), 'slug' => 'forum', 'parent_url' => $group_link, 'parent_slug' => $this->current_group->slug, 'screen_function' => 'groups_screen_group_forum', 'position' => 40, 'user_has_access' => $this->current_group->user_has_access, 'item_css_id' => 'forums');
}
if ($this->current_group->front_template || bp_is_active('activity')) {
/**
* If the theme is using a custom front, create activity subnav.
*/
if ($this->current_group->front_template && bp_is_active('activity')) {
$sub_nav[] = array('name' => _x('Activity', 'My Group screen nav', 'buddypress'), 'slug' => 'activity', 'parent_url' => $group_link, 'parent_slug' => $this->current_group->slug, 'screen_function' => 'groups_screen_group_activity', 'position' => 11, 'user_has_access' => $this->current_group->user_has_access, 'item_css_id' => 'activity', 'no_access_url' => $group_link);
}
/**
* Only add the members subnav if it's not the home's nav.
*/
$sub_nav[] = array('name' => sprintf(_x('Members %s', 'My Group screen nav', 'buddypress'), '<span>' . number_format($this->current_group->total_member_count) . '</span>'), 'slug' => 'members', 'parent_url' => $group_link, 'parent_slug' => $this->current_group->slug, 'screen_function' => 'groups_screen_group_members', 'position' => 60, 'user_has_access' => $this->current_group->user_has_access, 'item_css_id' => 'members', 'no_access_url' => $group_link);
}
if (bp_is_active('friends') && bp_groups_user_can_send_invites()) {
$sub_nav[] = array('name' => _x('Send Invites', 'My Group screen nav', 'buddypress'), 'slug' => 'send-invites', 'parent_url' => $group_link, 'parent_slug' => $this->current_group->slug, 'screen_function' => 'groups_screen_group_invite', 'item_css_id' => 'invite', 'position' => 70, 'user_has_access' => $this->current_group->user_has_access, 'no_access_url' => $group_link);
}
// If the user is a group admin, then show the group admin nav item.
if (bp_is_item_admin()) {
$sub_nav[] = array('name' => _x('Manage', 'My Group screen nav', 'buddypress'), 'slug' => 'admin', 'parent_url' => $group_link, 'parent_slug' => $this->current_group->slug, 'screen_function' => 'groups_screen_group_admin', 'position' => 1000, 'user_has_access' => true, 'item_css_id' => 'admin', 'no_access_url' => $group_link);
$admin_link = trailingslashit($group_link . 'admin');
// Common params to all nav items.
$default_params = array('parent_url' => $admin_link, 'parent_slug' => $this->current_group->slug . '_manage', 'screen_function' => 'groups_screen_group_admin', 'user_has_access' => bp_is_item_admin(), 'show_in_admin_bar' => true);
$sub_nav[] = array_merge(array('name' => __('Details', 'buddypress'), 'slug' => 'edit-details', 'position' => 0), $default_params);
$sub_nav[] = array_merge(array('name' => __('Settings', 'buddypress'), 'slug' => 'group-settings', 'position' => 10), $default_params);
if (!bp_disable_group_avatar_uploads() && buddypress()->avatar->show_avatars) {
$sub_nav[] = array_merge(array('name' => __('Photo', 'buddypress'), 'slug' => 'group-avatar', 'position' => 20), $default_params);
}
if (bp_group_use_cover_image_header()) {
$sub_nav[] = array_merge(array('name' => __('Cover Image', 'buddypress'), 'slug' => 'group-cover-image', 'position' => 25), $default_params);
}
$sub_nav[] = array_merge(array('name' => __('Members', 'buddypress'), 'slug' => 'manage-members', 'position' => 30), $default_params);
if ('private' == $this->current_group->status) {
$sub_nav[] = array_merge(array('name' => __('Requests', 'buddypress'), 'slug' => 'membership-requests', 'position' => 40), $default_params);
}
$sub_nav[] = array_merge(array('name' => __('Delete', 'buddypress'), 'slug' => 'delete-group', 'position' => 1000), $default_params);
}
foreach ($sub_nav as $nav) {
bp_core_new_subnav_item($nav, 'groups');
}
}
if (isset($this->current_group->user_has_access)) {
//.........这里部分代码省略.........
示例5: setup_nav
/**
* Setup BuddyBar navigation
*
* @global BuddyPress $bp The one true BuddyPress instance
*/
function setup_nav()
{
// Define local variables
$sub_nav = array();
// Add 'Groups' to the main navigation
$main_nav = array('name' => sprintf(__('Groups <span>%d</span>', 'buddypress'), groups_total_groups_for_user()), 'slug' => $this->slug, 'position' => 70, 'screen_function' => 'groups_screen_my_groups', 'default_subnav_slug' => 'my-groups', 'item_css_id' => $this->id);
$groups_link = trailingslashit(bp_loggedin_user_domain() . $this->slug);
// Add the My Groups nav item
$sub_nav[] = array('name' => __('Memberships', 'buddypress'), 'slug' => 'my-groups', 'parent_url' => $groups_link, 'parent_slug' => $this->slug, 'screen_function' => 'groups_screen_my_groups', 'position' => 10, 'item_css_id' => 'groups-my-groups');
// Add the Group Invites nav item
$sub_nav[] = array('name' => __('Invitations', 'buddypress'), 'slug' => 'invites', 'parent_url' => $groups_link, 'parent_slug' => $this->slug, 'screen_function' => 'groups_screen_group_invites', 'user_has_access' => bp_is_my_profile(), 'position' => 30);
parent::setup_nav($main_nav, $sub_nav);
if (bp_is_groups_component() && bp_is_single_item()) {
// Reset sub nav
$sub_nav = array();
// Add 'Groups' to the main navigation
$main_nav = array('name' => __('Memberships', 'buddypress'), 'slug' => $this->current_group->slug, 'position' => -1, 'screen_function' => 'groups_screen_group_home', 'default_subnav_slug' => $this->default_extension, 'item_css_id' => $this->id);
$group_link = bp_get_group_permalink($this->current_group);
// Add the "Home" subnav item, as this will always be present
$sub_nav[] = array('name' => _x('Home', 'Group home navigation title', 'buddypress'), 'slug' => 'home', 'parent_url' => $group_link, 'parent_slug' => $this->current_group->slug, 'screen_function' => 'groups_screen_group_home', 'position' => 10, 'item_css_id' => 'home');
// If this is a private group, and the user is not a member, show a "Request Membership" nav item.
if (is_user_logged_in() && !bp_current_user_can('bp_moderate') && !$this->current_group->is_user_member && !groups_check_for_membership_request(bp_loggedin_user_id(), $this->current_group->id) && $this->current_group->status == 'private') {
$sub_nav[] = array('name' => __('Request Membership', 'buddypress'), 'slug' => 'request-membership', 'parent_url' => $group_link, 'parent_slug' => $this->current_group->slug, 'screen_function' => 'groups_screen_group_request_membership', 'position' => 30);
}
// Forums are enabled and turned on
if ($this->current_group->enable_forum && bp_is_active('forums')) {
$sub_nav[] = array('name' => __('Forum', 'buddypress'), 'slug' => 'forum', 'parent_url' => $group_link, 'parent_slug' => $this->current_group->slug, 'screen_function' => 'groups_screen_group_forum', 'position' => 40, 'user_has_access' => $this->current_group->user_has_access, 'item_css_id' => 'forums');
}
$sub_nav[] = array('name' => sprintf(__('Members <span>%s</span>', 'buddypress'), number_format($this->current_group->total_member_count)), 'slug' => 'members', 'parent_url' => $group_link, 'parent_slug' => $this->current_group->slug, 'screen_function' => 'groups_screen_group_members', 'position' => 60, 'user_has_access' => $this->current_group->user_has_access, 'item_css_id' => 'members');
if (bp_is_active('friends') && bp_groups_user_can_send_invites()) {
$sub_nav[] = array('name' => __('Send Invites', 'buddypress'), 'slug' => 'send-invites', 'parent_url' => $group_link, 'parent_slug' => $this->current_group->slug, 'screen_function' => 'groups_screen_group_invite', 'item_css_id' => 'invite', 'position' => 70, 'user_has_access' => $this->current_group->user_has_access);
}
// If the user is a group mod or more, then show the group admin nav item
if (bp_is_item_admin() || bp_is_item_mod()) {
$sub_nav[] = array('name' => __('Admin', 'buddypress'), 'slug' => 'admin', 'parent_url' => $group_link, 'parent_slug' => $this->current_group->slug, 'screen_function' => 'groups_screen_group_admin', 'position' => 1000, 'user_has_access' => true, 'item_css_id' => 'admin');
}
parent::setup_nav($main_nav, $sub_nav);
}
if (isset($this->current_group->user_has_access)) {
do_action('groups_setup_nav', $this->current_group->user_has_access);
} else {
do_action('groups_setup_nav');
}
}
示例6: groups_setup_nav
function groups_setup_nav() {
global $bp;
if ( $bp->current_component == $bp->groups->slug && $group_id = BP_Groups_Group::group_exists($bp->current_action) ) {
/* This is a single group page. */
$bp->is_single_item = true;
$bp->groups->current_group = new BP_Groups_Group( $group_id );
/* Using "item" not "group" for generic support in other components. */
if ( is_super_admin() )
$bp->is_item_admin = 1;
else
$bp->is_item_admin = groups_is_user_admin( $bp->loggedin_user->id, $bp->groups->current_group->id );
/* If the user is not an admin, check if they are a moderator */
if ( !$bp->is_item_admin )
$bp->is_item_mod = groups_is_user_mod( $bp->loggedin_user->id, $bp->groups->current_group->id );
/* Is the logged in user a member of the group? */
$bp->groups->current_group->is_user_member = ( is_user_logged_in() && groups_is_user_member( $bp->loggedin_user->id, $bp->groups->current_group->id ) ) ? true : false;
/* Should this group be visible to the logged in user? */
$bp->groups->current_group->is_group_visible_to_member = ( 'public' == $bp->groups->current_group->status || $is_member ) ? true : false;
}
/* Add 'Groups' to the main navigation */
bp_core_new_nav_item( array( 'name' => sprintf( __( 'Groups <span>(%d)</span>', 'buddypress' ), groups_total_groups_for_user() ), 'slug' => $bp->groups->slug, 'position' => 70, 'screen_function' => 'groups_screen_my_groups', 'default_subnav_slug' => 'my-groups', 'item_css_id' => $bp->groups->id ) );
$groups_link = $bp->loggedin_user->domain . $bp->groups->slug . '/';
/* Add the subnav items to the groups nav item */
bp_core_new_subnav_item( array( 'name' => __( 'My Groups', 'buddypress' ), 'slug' => 'my-groups', 'parent_url' => $groups_link, 'parent_slug' => $bp->groups->slug, 'screen_function' => 'groups_screen_my_groups', 'position' => 10, 'item_css_id' => 'groups-my-groups' ) );
bp_core_new_subnav_item( array( 'name' => __( 'Invites', 'buddypress' ), 'slug' => 'invites', 'parent_url' => $groups_link, 'parent_slug' => $bp->groups->slug, 'screen_function' => 'groups_screen_group_invites', 'position' => 30, 'user_has_access' => bp_is_my_profile() ) );
if ( $bp->current_component == $bp->groups->slug ) {
if ( bp_is_my_profile() && !$bp->is_single_item ) {
$bp->bp_options_title = __( 'My Groups', 'buddypress' );
} else if ( !bp_is_my_profile() && !$bp->is_single_item ) {
$bp->bp_options_avatar = bp_core_fetch_avatar( array( 'item_id' => $bp->displayed_user->id, 'type' => 'thumb' ) );
$bp->bp_options_title = $bp->displayed_user->fullname;
} else if ( $bp->is_single_item ) {
// We are viewing a single group, so set up the
// group navigation menu using the $bp->groups->current_group global.
/* When in a single group, the first action is bumped down one because of the
group name, so we need to adjust this and set the group name to current_item. */
$bp->current_item = $bp->current_action;
$bp->current_action = $bp->action_variables[0];
array_shift($bp->action_variables);
$bp->bp_options_title = $bp->groups->current_group->name;
if ( !$bp->bp_options_avatar = bp_core_fetch_avatar( array( 'item_id' => $bp->groups->current_group->id, 'object' => 'group', 'type' => 'thumb', 'avatar_dir' => 'group-avatars', 'alt' => __( 'Group Avatar', 'buddypress' ) ) ) )
$bp->bp_options_avatar = '<img src="' . esc_attr( $group->avatar_full ) . '" class="avatar" alt="' . esc_attr( $group->name ) . '" />';
$group_link = $bp->root_domain . '/' . $bp->groups->slug . '/' . $bp->groups->current_group->slug . '/';
// If this is a private or hidden group, does the user have access?
if ( 'private' == $bp->groups->current_group->status || 'hidden' == $bp->groups->current_group->status ) {
if ( $bp->groups->current_group->is_user_member && is_user_logged_in() || is_super_admin() )
$bp->groups->current_group->user_has_access = true;
else
$bp->groups->current_group->user_has_access = false;
} else {
$bp->groups->current_group->user_has_access = true;
}
/* Reset the existing subnav items */
bp_core_reset_subnav_items($bp->groups->slug);
/* Add a new default subnav item for when the groups nav is selected. */
bp_core_new_nav_default( array( 'parent_slug' => $bp->groups->slug, 'screen_function' => 'groups_screen_group_home', 'subnav_slug' => 'home' ) );
/* Add the "Home" subnav item, as this will always be present */
bp_core_new_subnav_item( array( 'name' => __( 'Home', 'buddypress' ), 'slug' => 'home', 'parent_url' => $group_link, 'parent_slug' => $bp->groups->slug, 'screen_function' => 'groups_screen_group_home', 'position' => 10, 'item_css_id' => 'home' ) );
/* If the user is a group mod or more, then show the group admin nav item */
if ( $bp->is_item_mod || $bp->is_item_admin )
bp_core_new_subnav_item( array( 'name' => __( 'Admin', 'buddypress' ), 'slug' => 'admin', 'parent_url' => $group_link, 'parent_slug' => $bp->groups->slug, 'screen_function' => 'groups_screen_group_admin', 'position' => 20, 'user_has_access' => ( $bp->is_item_admin + (int)$bp->is_item_mod ), 'item_css_id' => 'admin' ) );
// If this is a private group, and the user is not a member, show a "Request Membership" nav item.
if ( !is_super_admin() && is_user_logged_in() && !$bp->groups->current_group->is_user_member && !groups_check_for_membership_request( $bp->loggedin_user->id, $bp->groups->current_group->id ) && $bp->groups->current_group->status == 'private' )
bp_core_new_subnav_item( array( 'name' => __( 'Request Membership', 'buddypress' ), 'slug' => 'request-membership', 'parent_url' => $group_link, 'parent_slug' => $bp->groups->slug, 'screen_function' => 'groups_screen_group_request_membership', 'position' => 30 ) );
if ( $bp->groups->current_group->enable_forum && function_exists('bp_forums_setup') )
bp_core_new_subnav_item( array( 'name' => __( 'Forum', 'buddypress' ), 'slug' => 'forum', 'parent_url' => $group_link, 'parent_slug' => $bp->groups->slug, 'screen_function' => 'groups_screen_group_forum', 'position' => 40, 'user_has_access' => $bp->groups->current_group->user_has_access, 'item_css_id' => 'forums' ) );
bp_core_new_subnav_item( array( 'name' => sprintf( __( 'Members (%s)', 'buddypress' ), number_format( $bp->groups->current_group->total_member_count ) ), 'slug' => 'members', 'parent_url' => $group_link, 'parent_slug' => $bp->groups->slug, 'screen_function' => 'groups_screen_group_members', 'position' => 60, 'user_has_access' => $bp->groups->current_group->user_has_access, 'item_css_id' => 'members' ) );
if ( is_user_logged_in() && groups_is_user_member( $bp->loggedin_user->id, $bp->groups->current_group->id ) ) {
if ( function_exists('friends_install') )
bp_core_new_subnav_item( array( 'name' => __( 'Send Invites', 'buddypress' ), 'slug' => 'send-invites', 'parent_url' => $group_link, 'parent_slug' => $bp->groups->slug, 'screen_function' => 'groups_screen_group_invite', 'item_css_id' => 'invite', 'position' => 70, 'user_has_access' => $bp->groups->current_group->user_has_access ) );
}
}
//.........这里部分代码省略.........
示例7: bp_group_show_no_groups_message
function bp_group_show_no_groups_message()
{
global $bp;
if (!groups_total_groups_for_user($bp->displayed_user->id)) {
return true;
}
return false;
}