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


PHP groups_send_membership_request函数代码示例

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


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

示例1: 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

示例2: 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

示例3: 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

示例4: groups_screen_group_request_membership

/**
 * Handle the display of a group's Request Membership page.
 */
function groups_screen_group_request_membership()
{
    if (!is_user_logged_in()) {
        return false;
    }
    $bp = buddypress();
    if ('private' != $bp->groups->current_group->status) {
        return false;
    }
    // If the user is already invited, accept invitation.
    if (groups_check_user_has_invite(bp_loggedin_user_id(), $bp->groups->current_group->id)) {
        if (groups_accept_invite(bp_loggedin_user_id(), $bp->groups->current_group->id)) {
            bp_core_add_message(__('Group invite accepted', 'buddypress'));
        } else {
            bp_core_add_message(__('There was an error accepting the group invitation. Please try again.', 'buddypress'), 'error');
        }
        bp_core_redirect(bp_get_group_permalink($bp->groups->current_group));
    }
    // If the user has submitted a request, send it.
    if (isset($_POST['group-request-send'])) {
        // Check the nonce.
        if (!check_admin_referer('groups_request_membership')) {
            return false;
        }
        if (!groups_send_membership_request(bp_loggedin_user_id(), $bp->groups->current_group->id)) {
            bp_core_add_message(__('There was an error sending your group membership request. Please try again.', 'buddypress'), 'error');
        } else {
            bp_core_add_message(__('Your membership request was sent to the group administrator successfully. You will be notified when the group administrator responds to your request.', 'buddypress'));
        }
        bp_core_redirect(bp_get_group_permalink($bp->groups->current_group));
    }
    /**
     * Fires before the loading of a group's Request Memebership page.
     *
     * @since 1.0.0
     *
     * @param int $id ID of the group currently being displayed.
     */
    do_action('groups_screen_group_request_membership', $bp->groups->current_group->id);
    /**
     * Filters the template to load for a group's Request Membership page.
     *
     * @since 1.0.0
     *
     * @param string $value Path to a group's Request Membership template.
     */
    bp_core_load_template(apply_filters('groups_template_group_request_membership', 'groups/single/home'));
}
开发者ID:swissspidy,项目名称:BuddyPress,代码行数:51,代码来源:bp-groups-screens.php

示例5: test_groups_accept_all_pending_membership_requests

 /**
  * @group groups_accept_all_pending_membership_requests
  * @group group_membership_requests
  * @group group_membership
  */
 public function test_groups_accept_all_pending_membership_requests()
 {
     $u1 = $this->factory->user->create();
     $u2 = $this->factory->user->create();
     $u3 = $this->factory->user->create();
     $g1 = $this->factory->group->create();
     // Create membership request
     groups_send_membership_request($u1, $g1);
     groups_send_membership_request($u2, $g1);
     groups_send_membership_request($u3, $g1);
     groups_accept_all_pending_membership_requests($g1);
     // All users should now be group members.
     $members = new BP_Group_Member_Query(array('group_id' => $g1));
     $this->assertEqualSets(array($u1, $u2, $u3), $members->user_ids);
 }
开发者ID:jasonmcalpin,项目名称:BuddyPress,代码行数:20,代码来源:class-bp-groups-member.php

示例6: groups_screen_group_request_membership

/**
 * Handle the display of a group's Request Membership page.
 */
function groups_screen_group_request_membership()
{
    global $bp;
    if (!is_user_logged_in()) {
        return false;
    }
    $bp = buddypress();
    if ('private' != $bp->groups->current_group->status) {
        return false;
    }
    // If the user is already invited, accept invitation
    if (groups_check_user_has_invite(bp_loggedin_user_id(), $bp->groups->current_group->id)) {
        if (groups_accept_invite(bp_loggedin_user_id(), $bp->groups->current_group->id)) {
            bp_core_add_message(__('Group invite accepted', 'buddypress'));
        } else {
            bp_core_add_message(__('There was an error accepting the group invitation. Please try again.', 'buddypress'), 'error');
        }
        bp_core_redirect(bp_get_group_permalink($bp->groups->current_group));
    }
    // If the user has submitted a request, send it.
    if (isset($_POST['group-request-send'])) {
        // Check the nonce
        if (!check_admin_referer('groups_request_membership')) {
            return false;
        }
        if (!groups_send_membership_request(bp_loggedin_user_id(), $bp->groups->current_group->id)) {
            bp_core_add_message(__('There was an error sending your group membership request. Please try again.', 'buddypress'), 'error');
        } else {
            bp_core_add_message(__('Your membership request was sent to the group administrator successfully. You will be notified when the group administrator responds to your request.', 'buddypress'));
        }
        bp_core_redirect(bp_get_group_permalink($bp->groups->current_group));
    }
    do_action('groups_screen_group_request_membership', $bp->groups->current_group->id);
    bp_core_load_template(apply_filters('groups_template_group_request_membership', 'groups/single/home'));
}
开发者ID:sdh100shaun,项目名称:pantheon,代码行数:38,代码来源:bp-groups-screens.php

示例7: groups_screen_group_request_membership

function groups_screen_group_request_membership() {
	global $bp;

	if ( !is_user_logged_in() )
		return false;

	if ( 'private' == $bp->groups->current_group->status ) {
		// If the user has submitted a request, send it.
		if ( isset( $_POST['group-request-send']) ) {
			/* Check the nonce first. */
			if ( !check_admin_referer( 'groups_request_membership' ) )
				return false;

			if ( !groups_send_membership_request( $bp->loggedin_user->id, $bp->groups->current_group->id ) ) {
				bp_core_add_message( __( 'There was an error sending your group membership request, please try again.', 'buddypress' ), 'error' );
			} else {
				bp_core_add_message( __( 'Your membership request was sent to the group administrator successfully. You will be notified when the group administrator responds to your request.', 'buddypress' ) );
			}
			bp_core_redirect( bp_get_group_permalink( $bp->groups->current_group ) );
		}

		do_action( 'groups_screen_group_request_membership', $bp->groups->current_group->id );

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

示例8: test_group_parameter_should_be_obeyed

 /**
  * @group BP6319
  */
 public function test_group_parameter_should_be_obeyed()
 {
     $u = $this->factory->user->create();
     $groups = $this->factory->group->create_many(2, array('status' => 'private'));
     $this->set_current_user($u);
     // Fake the current group.
     $GLOBALS['groups_template'] = new stdClass();
     $GLOBALS['groups_template']->group = groups_get_group($groups[0]);
     groups_send_membership_request($u, $groups[1]);
     $group1 = groups_get_group(array('group_id' => $groups[1], 'populate_extras' => true));
     $found = get_echo('bp_group_status_message', array($group1));
     $expected = __('This is a private group. Your membership request is awaiting approval from the group administrator.', 'buddypress');
     $this->assertSame($expected, $found);
 }
开发者ID:CompositeUK,项目名称:clone.BuddyPress,代码行数:17,代码来源:bpGroupStatusMessage.php

示例9: test_membership_request_notifications_should_be_cleared_when_request_is_accepted

 /**
  * @group BP7375
  */
 public function test_membership_request_notifications_should_be_cleared_when_request_is_accepted()
 {
     $users = $this->factory->user->create_many(3);
     $this->add_user_to_group($users[0], $this->group, array('is_admin' => 1));
     $this->add_user_to_group($users[1], $this->group, array('is_admin' => 1));
     groups_send_membership_request($users[2], $this->group);
     // Both admins should get a notification.
     $get_args = array('user_id' => $users[0], 'item_id' => $this->group, 'secondary_item_id' => $users[2], 'component_action' => 'new_membership_request', 'is_new' => true);
     $u0_notifications = BP_Notifications_Notification::get($get_args);
     $u1_notifications = BP_Notifications_Notification::get($get_args);
     $this->assertNotEmpty($u0_notifications);
     $this->assertNotEmpty($u1_notifications);
     $this->assertTrue(groups_invite_user(array('user_id' => $users[2], 'group_id' => $this->group)));
     $u0_notifications = BP_Notifications_Notification::get($get_args);
     $u1_notifications = BP_Notifications_Notification::get($get_args);
     $this->assertEmpty($u0_notifications);
     $this->assertEmpty($u1_notifications);
 }
开发者ID:CompositeUK,项目名称:clone.BuddyPress,代码行数:21,代码来源:notifications.php

示例10: test_cache_should_be_invalidated_on_group_request_acceptance

 /**
  * @group cache
  */
 public function test_cache_should_be_invalidated_on_group_request_acceptance()
 {
     // For `wp_mail()`.
     $server_name = isset($_SERVER['SERVER_NAME']) ? $_SERVER['SERVER_NAME'] : null;
     $_SERVER['SERVER_NAME'] = '';
     groups_send_membership_request(self::$user, self::$groups[2]);
     // Populate cache.
     $g1 = bp_get_user_groups(self::$user);
     $m = new BP_Groups_Member(self::$user, self::$groups[2]);
     groups_accept_membership_request($m->id, self::$user, self::$groups[2]);
     // For `wp_mail()`.
     if (is_null($server_name)) {
         unset($_SERVER['SERVER_NAME']);
     } else {
         $_SERVER['SERVER_NAME'] = $server_name;
     }
     $expected = array(self::$groups[0], self::$groups[1], self::$groups[2]);
     $found = bp_get_user_groups(self::$user);
     $this->assertEqualSets($expected, array_keys($found));
 }
开发者ID:CompositeUK,项目名称:clone.BuddyPress,代码行数:23,代码来源:bpGetUserGroups.php

示例11: test_total_member_count_groups_accept_membership_request

 /**
  * @group total_member_count
  * @group groups_accept_membership_request
  */
 public function test_total_member_count_groups_accept_membership_request()
 {
     $u1 = $this->factory->user->create();
     $u2 = $this->factory->user->create();
     $g = $this->factory->group->create(array('creator_id' => $u1));
     groups_send_membership_request($u2, $g);
     groups_accept_membership_request(0, $u2, $g);
     $this->assertEquals(2, groups_get_groupmeta($g, 'total_member_count'));
 }
开发者ID:CompositeUK,项目名称:clone.BuddyPress,代码行数:13,代码来源:functions.php


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