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


PHP groups_leave_group函数代码示例

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


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

示例1: bp_dtheme_ajax_joinleave_group

function bp_dtheme_ajax_joinleave_group()
{
    global $bp;
    if (groups_is_user_banned($bp->loggedin_user->id, $_POST['gid'])) {
        return false;
    }
    if (!($group = new BP_Groups_Group($_POST['gid'], false, false))) {
        return false;
    }
    if (!groups_is_user_member($bp->loggedin_user->id, $group->id)) {
        if ('public' == $group->status) {
            check_ajax_referer('groups_join_group');
            if (!groups_join_group($group->id)) {
                _e('Error joining group', 'buddypress');
            } else {
                echo '<a id="group-' . esc_attr($group->id) . '" class="leave-group" rel="leave" title="' . __('Leave Group', 'buddypress') . '" href="' . wp_nonce_url(bp_get_group_permalink($group) . 'leave-group', 'groups_leave_group') . '">' . __('Leave Group', 'buddypress') . '</a>';
            }
        } else {
            if ('private' == $group->status) {
                check_ajax_referer('groups_request_membership');
                if (!groups_send_membership_request($bp->loggedin_user->id, $group->id)) {
                    _e('Error requesting membership', 'buddypress');
                } else {
                    echo '<a id="group-' . esc_attr($group->id) . '" class="membership-requested" rel="membership-requested" title="' . __('Membership Requested', 'buddypress') . '" href="' . bp_get_group_permalink($group) . '">' . __('Membership Requested', 'buddypress') . '</a>';
                }
            }
        }
    } else {
        check_ajax_referer('groups_leave_group');
        if (!groups_leave_group($group->id)) {
            _e('Error leaving group', 'buddypress');
        } else {
            if ('public' == $group->status) {
                echo '<a id="group-' . esc_attr($group->id) . '" class="join-group" rel="join" title="' . __('Join Group', 'buddypress') . '" href="' . wp_nonce_url(bp_get_group_permalink($group) . 'join', 'groups_join_group') . '">' . __('Join Group', 'buddypress') . '</a>';
            } else {
                if ('private' == $group->status) {
                    echo '<a id="group-' . esc_attr($group->id) . '" class="request-membership" rel="join" title="' . __('Request Membership', 'buddypress') . '" href="' . wp_nonce_url(bp_get_group_permalink($group) . 'request-membership', 'groups_send_membership_request') . '">' . __('Request Membership', 'buddypress') . '</a>';
                }
            }
        }
    }
}
开发者ID:hscale,项目名称:webento,代码行数:42,代码来源:ajax.php

示例2: bp_dtheme_ajax_joinleave_group

/**
 * Join or leave a group when clicking the "join/leave" button via a POST request.
 *
 * @return string HTML
 * @since BuddyPress (1.2)
 */
function bp_dtheme_ajax_joinleave_group()
{
    // Bail if not a POST action
    if ('POST' !== strtoupper($_SERVER['REQUEST_METHOD'])) {
        return;
    }
    if (groups_is_user_banned(bp_loggedin_user_id(), $_POST['gid'])) {
        return;
    }
    if (!($group = groups_get_group(array('group_id' => $_POST['gid'])))) {
        return;
    }
    if (!groups_is_user_member(bp_loggedin_user_id(), $group->id)) {
        if ('public' == $group->status) {
            check_ajax_referer('groups_join_group');
            if (!groups_join_group($group->id)) {
                _e('Error joining group', 'logicalboneshug');
            } else {
                echo '<a id="group-' . esc_attr($group->id) . '" class="leave-group" rel="leave" title="' . __('Leave Group', 'logicalboneshug') . '" href="' . wp_nonce_url(bp_get_group_permalink($group) . 'leave-group', 'groups_leave_group') . '">' . __('Leave Group', 'logicalboneshug') . '</a>';
            }
        } elseif ('private' == $group->status) {
            check_ajax_referer('groups_request_membership');
            if (!groups_send_membership_request(bp_loggedin_user_id(), $group->id)) {
                _e('Error requesting membership', 'logicalboneshug');
            } else {
                echo '<a id="group-' . esc_attr($group->id) . '" class="membership-requested" rel="membership-requested" title="' . __('Membership Requested', 'logicalboneshug') . '" href="' . bp_get_group_permalink($group) . '">' . __('Membership Requested', 'logicalboneshug') . '</a>';
            }
        }
    } else {
        check_ajax_referer('groups_leave_group');
        if (!groups_leave_group($group->id)) {
            _e('Error leaving group', 'logicalboneshug');
        } elseif ('public' == $group->status) {
            echo '<a id="group-' . esc_attr($group->id) . '" class="join-group" rel="join" title="' . __('Join Group', 'logicalboneshug') . '" href="' . wp_nonce_url(bp_get_group_permalink($group) . 'join', 'groups_join_group') . '">' . __('Join Group', 'logicalboneshug') . '</a>';
        } elseif ('private' == $group->status) {
            echo '<a id="group-' . esc_attr($group->id) . '" class="request-membership" rel="join" title="' . __('Request Membership', 'logicalboneshug') . '" href="' . wp_nonce_url(bp_get_group_permalink($group) . 'request-membership', 'groups_send_membership_request') . '">' . __('Request Membership', 'logicalboneshug') . '</a>';
        }
    }
    exit;
}
开发者ID:raminjan,项目名称:logicalbones_hug,代码行数:46,代码来源:ajax.php

示例3: bp_legacy_theme_ajax_joinleave_group

/**
 * Join or leave a group when clicking the "join/leave" button via a POST request.
 *
 * @return string HTML
 * @since BuddyPress (1.2)
 */
function bp_legacy_theme_ajax_joinleave_group()
{
    // Bail if not a POST action
    if ('POST' !== strtoupper($_SERVER['REQUEST_METHOD'])) {
        return;
    }
    // Cast gid as integer
    $group_id = (int) $_POST['gid'];
    if (groups_is_user_banned(bp_loggedin_user_id(), $group_id)) {
        return;
    }
    if (!($group = groups_get_group(array('group_id' => $group_id)))) {
        return;
    }
    if (!groups_is_user_member(bp_loggedin_user_id(), $group->id)) {
        if ('public' == $group->status) {
            check_ajax_referer('groups_join_group');
            if (!groups_join_group($group->id)) {
                _e('Error joining group', 'buddypress');
            } else {
                echo '<a id="group-' . esc_attr($group->id) . '" class="leave-group" rel="leave" title="' . __('Leave Group', 'buddypress') . '" href="' . wp_nonce_url(bp_get_group_permalink($group) . 'leave-group', 'groups_leave_group') . '">' . __('Leave Group', 'buddypress') . '</a>';
            }
        } elseif ('private' == $group->status) {
            // If the user has already been invited, then this is
            // an Accept Invitation button
            if (groups_check_user_has_invite(bp_loggedin_user_id(), $group->id)) {
                check_ajax_referer('groups_accept_invite');
                if (!groups_accept_invite(bp_loggedin_user_id(), $group->id)) {
                    _e('Error requesting membership', 'buddypress');
                } else {
                    echo '<a id="group-' . esc_attr($group->id) . '" class="leave-group" rel="leave" title="' . __('Leave Group', 'buddypress') . '" href="' . wp_nonce_url(bp_get_group_permalink($group) . 'leave-group', 'groups_leave_group') . '">' . __('Leave Group', 'buddypress') . '</a>';
                }
                // Otherwise, it's a Request Membership button
            } else {
                check_ajax_referer('groups_request_membership');
                if (!groups_send_membership_request(bp_loggedin_user_id(), $group->id)) {
                    _e('Error requesting membership', 'buddypress');
                } else {
                    echo '<a id="group-' . esc_attr($group->id) . '" class="membership-requested" rel="membership-requested" title="' . __('Membership Requested', 'buddypress') . '" href="' . bp_get_group_permalink($group) . '">' . __('Membership Requested', 'buddypress') . '</a>';
                }
            }
        }
    } else {
        check_ajax_referer('groups_leave_group');
        if (!groups_leave_group($group->id)) {
            _e('Error leaving group', 'buddypress');
        } elseif ('public' == $group->status) {
            echo '<a id="group-' . esc_attr($group->id) . '" class="join-group" rel="join" title="' . __('Join Group', 'buddypress') . '" href="' . wp_nonce_url(bp_get_group_permalink($group) . 'join', 'groups_join_group') . '">' . __('Join Group', 'buddypress') . '</a>';
        } elseif ('private' == $group->status) {
            echo '<a id="group-' . esc_attr($group->id) . '" class="request-membership" rel="join" title="' . __('Request Membership', 'buddypress') . '" href="' . wp_nonce_url(bp_get_group_permalink($group) . 'request-membership', 'groups_send_membership_request') . '">' . __('Request Membership', 'buddypress') . '</a>';
        }
    }
    exit;
}
开发者ID:kosir,项目名称:thatcamp-org,代码行数:60,代码来源:buddypress-functions.php

示例4: test_groups_leave_group_multiple_admins_allow_leave

 /**
  * @group groups_leave_group
  * @group group_membership
  */
 public function test_groups_leave_group_multiple_admins_allow_leave()
 {
     $old_current_user = get_current_user_id();
     $u1 = $this->factory->user->create();
     $g = $this->factory->group->create(array('creator_id' => $u1));
     $u2 = $this->factory->user->create();
     $this->add_user_to_group($u2, $g);
     $m2 = new BP_Groups_Member($u2, $g);
     $m2->promote('admin');
     $before = groups_get_total_member_count($g);
     $this->set_current_user($u1);
     groups_leave_group($g, $u1);
     $after = groups_get_total_member_count($g);
     $this->assertEquals($before - 1, $after);
     $this->set_current_user($old_current_user);
 }
开发者ID:jasonmcalpin,项目名称:BuddyPress,代码行数:20,代码来源:class-bp-groups-member.php

示例5: groups_action_leave_group

/**
 * Catch and process "Leave Group" button clicks.
 *
 * When a group member clicks on the "Leave Group" button from a group's page,
 * this function is run.
 *
 * Note: When leaving a group from the group directory, AJAX is used and
 * another function handles this. See {@link bp_legacy_theme_ajax_joinleave_group()}.
 *
 * @since BuddyPress (1.2.4)
 */
function groups_action_leave_group()
{
    if (!bp_is_single_item() || !bp_is_groups_component() || !bp_is_current_action('leave-group')) {
        return false;
    }
    // Nonce check
    if (!check_admin_referer('groups_leave_group')) {
        return false;
    }
    // User wants to leave any group
    if (groups_is_user_member(bp_loggedin_user_id(), bp_get_current_group_id())) {
        $bp = buddypress();
        // Stop sole admins from abandoning their group
        $group_admins = groups_get_group_admins(bp_get_current_group_id());
        if (1 == count($group_admins) && $group_admins[0]->user_id == bp_loggedin_user_id()) {
            bp_core_add_message(__('This group must have at least one admin', 'buddypress'), 'error');
        } elseif (!groups_leave_group($bp->groups->current_group->id)) {
            bp_core_add_message(__('There was an error leaving the group.', 'buddypress'), 'error');
        } else {
            bp_core_add_message(__('You successfully left the group.', 'buddypress'));
        }
        $redirect = bp_get_group_permalink(groups_get_current_group());
        if ('hidden' == $bp->groups->current_group->status) {
            $redirect = trailingslashit(bp_loggedin_user_domain() . bp_get_groups_slug());
        }
        bp_core_redirect($redirect);
    }
    bp_core_load_template(apply_filters('groups_template_group_home', 'groups/single/home'));
}
开发者ID:eresyyl,项目名称:mk,代码行数:40,代码来源:bp-groups-actions.php

示例6: bp_group_management_admin_edit


//.........这里部分代码省略.........
            } else {
                ?>
				<div id="message" class="updated fade"><p><?php 
                _e('Member promoted to admin', 'bp-group-management');
                ?>
</p></div>
			<?php 
            }
            break;
        case "add":
            if (!check_admin_referer('bp-group-management-action_add')) {
                return false;
            }
            if (!bp_group_management_join_group($id, $member_id)) {
                ?>
				<div id="message" class="updated fade"><p><?php 
                _e('Sorry, there was an error.', 'bp-group-management');
                ?>
</p></div>
			<?php 
            } else {
                ?>
				<div id="message" class="updated fade"><p><?php 
                _e('User added to group', 'bp-group-management');
                ?>
</p></div>
			<?php 
            }
            break;
        case "remove":
            if (!check_admin_referer('bp-group-management-action_remove')) {
                return false;
            }
            if (!groups_leave_group($id, $_GET['member_id'])) {
                ?>
				<div id="message" class="updated fade"><p><?php 
                _e('Sorry, there was an error.', 'bp-group-management');
                ?>
</p></div>
			<?php 
            } else {
                ?>
				<div id="message" class="updated fade"><p><?php 
                _e('User removed from group', 'bp-group-management');
                ?>
</p></div>
			<?php 
            }
            break;
        default:
            do_action('bp_gm_member_action', $group, $id, $member_action, $member_id);
            break;
    }
    ?>


	    <h2><?php 
    _e('Group Management', 'bp-group-management');
    ?>
 : <?php 
    echo bp_get_group_name($group);
    ?>
</h2>

	    <a href="admin.php?page=bp-group-management">&larr; <?php 
    _e('Group index', 'bp-group-management');
开发者ID:adisonc,项目名称:MaineLearning,代码行数:67,代码来源:bp-group-management-bp-functions.php

示例7: groups_action_leave_group

function groups_action_leave_group() {
	global $bp;

	if ( !$bp->is_single_item || $bp->current_component != $bp->groups->slug || $bp->current_action != 'leave-group' )
		return false;

	// Nonce check
	if ( !check_admin_referer( 'groups_leave_group' ) )
		return false;

	// User wants to leave any group
	if ( groups_is_user_member( $bp->loggedin_user->id, $bp->groups->current_group->id ) ) {
		if ( !groups_leave_group( $bp->groups->current_group->id ) ) {
			bp_core_add_message( __( 'There was an error leaving the group.', 'buddypress' ), 'error' );
		} else {
			bp_core_add_message( __( 'You successfully left the group.', 'buddypress' ) );
		}
		bp_core_redirect( bp_get_group_permalink( $bp->groups->current_group ) );
	}

	bp_core_load_template( apply_filters( 'groups_template_group_home', 'groups/single/home' ) );
}
开发者ID:n-sane,项目名称:zaroka,代码行数:22,代码来源:bp-groups.php

示例8: groups_screen_group_leave

function groups_screen_group_leave()
{
    global $bp;
    global $group_obj;
    if ($bp->is_single_item) {
        if (isset($bp->action_variables) && 'yes' == $bp->action_variables[0]) {
            // Check if the user is the group admin first.
            if (groups_is_group_admin($bp->loggedin_user->id, $group_obj->id)) {
                bp_core_add_message(__('As the only group administrator, you cannot leave this group.', 'buddypress'), 'error');
                bp_core_redirect(bp_get_group_permalink($group_obj));
            }
            // remove the user from the group.
            if (!groups_leave_group($group_obj->id)) {
                bp_core_add_message(__('There was an error leaving the group. Please try again.', 'buddypress'), 'error');
                bp_core_redirect(bp_get_group_permalink($group_obj));
            } else {
                bp_core_add_message(__('You left the group successfully.', 'buddypress'));
                bp_core_redirect($bp->loggedin_user->domain . $bp->groups->slug);
            }
        } else {
            if (isset($bp->action_variables) && 'no' == $bp->action_variables[0]) {
                bp_core_redirect(bp_get_group_permalink($group_obj));
            } else {
                do_action('groups_screen_group_leave', $group_obj->id);
                // Show leave group page
                bp_core_load_template(apply_filters('groups_template_group_leave', 'groups/leave-group-confirm'));
            }
        }
    }
}
开发者ID:alvaropereyra,项目名称:shrekcms,代码行数:30,代码来源:bp-groups.php

示例9: test_wp_idea_stream_groups_member_leave_public_group

 /**
  * @group remove_from_group
  */
 public function test_wp_idea_stream_groups_member_leave_public_group()
 {
     $bp = buddypress();
     // Set current group
     $bp->groups->current_group = groups_get_group(array('group_id' => $this->group_id, 'populate_extras' => true));
     $u = $this->factory->user->create();
     groups_join_group($this->group_id, $u);
     $idea1 = $this->factory->idea->create(array('author' => $u, 'metas' => array('group_id' => $this->group_id)));
     $idea2 = $this->factory->idea->create(array('author' => $u, 'metas' => array('group_id' => $this->group_id)));
     $this->set_current_user($u);
     groups_leave_group($this->group_id, $u);
     // Check metas
     $this->assertEmpty(wp_idea_stream_ideas_get_meta($idea1, 'group_id'));
     $this->assertEmpty(wp_idea_stream_ideas_get_meta($idea2, 'group_id'));
     $ideas = wp_idea_stream_ideas_get_ideas(array('include' => array($idea1, $idea2)));
     $public_ideas = wp_filter_object_list($ideas['ideas'], array('post_status' => 'publish'), 'and', 'ID');
     $this->assertEqualSets(array($idea1, $idea2), $public_ideas, 'When a member leaves the group, ideas should always be public');
 }
开发者ID:BoweFrankema,项目名称:wp-idea-stream,代码行数:21,代码来源:groups.php

示例10: test_cache_should_be_invalidated_on_group_leave

 /**
  * @group cache
  */
 public function test_cache_should_be_invalidated_on_group_leave()
 {
     // Populate cache.
     $g1 = bp_get_user_groups(self::$user);
     groups_leave_group(self::$groups[1], self::$user);
     $expected = array(self::$groups[0]);
     $found = bp_get_user_groups(self::$user);
     $this->assertEqualSets($expected, array_keys($found));
 }
开发者ID:CompositeUK,项目名称:clone.BuddyPress,代码行数:12,代码来源:bpGetUserGroups.php

示例11: test_total_member_count_groups_leave_group

 /**
  * @group total_member_count
  * @group groups_leave_group
  */
 public function test_total_member_count_groups_leave_group()
 {
     $u1 = $this->factory->user->create();
     $g1 = $this->factory->group->create(array('creator_id' => $u1));
     groups_join_group($g1, $u1);
     groups_leave_group($g1, $u1);
     $this->assertEquals(1, groups_get_groupmeta($g1, 'total_member_count'));
 }
开发者ID:CompositeUK,项目名称:clone.BuddyPress,代码行数:12,代码来源:functions.php

示例12: settings_screen_save

 function settings_screen_save($group_id = NULL)
 {
     global $bp;
     // Make sure we have the group ID
     $group_id = $_POST['group_id'];
     if (!$group_id) {
         $group_id = $bp->groups->current_group->id;
     }
     // Set error redirect based on save method
     $redirect_url = $bp->root_domain . '/' . $bp->groups->slug . '/create/step/' . $this->slug;
     // Email cannot be empty
     if (empty($_POST['editable-guild-leader'])) {
         bp_core_add_message('You must enter a valid email address.', 'error');
         bp_core_redirect($redirect_url);
         exit;
     }
     // Make sure the nonce checks
     check_admin_referer('groups_create_save_' . $this->slug);
     // Get the leader by email
     $leader_email = sanitize_email($_POST['editable-guild-leader']);
     $leader = get_user_by('email', $leader_email);
     // If we don't recognize the email, bail out
     if (empty($leader)) {
         bp_core_add_message('This email address is not recognized.', 'error');
         bp_core_redirect($redirect_url);
         exit;
     }
     // Otherwise, set the group leader, and remove the creator
     $leader_id = $leader->ID;
     if ($leader_id != get_current_user_id()) {
         groups_accept_invite($leader_id, $group_id);
         $member = new BP_Groups_Member($leader_id, $group_id);
         $member->promote('admin');
         groups_leave_group($group_id, $creator_id);
     }
 }
开发者ID:tamriel-foundry,项目名称:apoc2,代码行数:36,代码来源:groups.php


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