本文整理汇总了PHP中groups_accept_membership_request函数的典型用法代码示例。如果您正苦于以下问题:PHP groups_accept_membership_request函数的具体用法?PHP groups_accept_membership_request怎么用?PHP groups_accept_membership_request使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了groups_accept_membership_request函数的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: groups_screen_group_admin_requests
/**
* Handle the display of Admin > Membership Requests.
*/
function groups_screen_group_admin_requests()
{
$bp = buddypress();
if ('membership-requests' != bp_get_group_current_admin_tab()) {
return false;
}
if (!bp_is_item_admin() || 'public' == $bp->groups->current_group->status) {
return false;
}
$request_action = (string) bp_action_variable(1);
$membership_id = (int) bp_action_variable(2);
if (!empty($request_action) && !empty($membership_id)) {
if ('accept' == $request_action && is_numeric($membership_id)) {
// Check the nonce first.
if (!check_admin_referer('groups_accept_membership_request')) {
return false;
}
// Accept the membership request.
if (!groups_accept_membership_request($membership_id)) {
bp_core_add_message(__('There was an error accepting the membership request. Please try again.', 'buddypress'), 'error');
} else {
bp_core_add_message(__('Group membership request accepted', 'buddypress'));
}
} elseif ('reject' == $request_action && is_numeric($membership_id)) {
/* Check the nonce first. */
if (!check_admin_referer('groups_reject_membership_request')) {
return false;
}
// Reject the membership request.
if (!groups_reject_membership_request($membership_id)) {
bp_core_add_message(__('There was an error rejecting the membership request. Please try again.', 'buddypress'), 'error');
} else {
bp_core_add_message(__('Group membership request rejected', 'buddypress'));
}
}
/**
* Fires before the redirect if a group membership request has been handled.
*
* @since 1.0.0
*
* @param int $id ID of the group that was edited.
* @param string $request_action Membership request action being performed.
* @param int $membership_id The key of the action_variables array that you want.
*/
do_action('groups_group_request_managed', $bp->groups->current_group->id, $request_action, $membership_id);
bp_core_redirect(bp_get_group_permalink(groups_get_current_group()) . 'admin/membership-requests/');
}
/**
* Fires before the loading of the group membership request page template.
*
* @since 1.0.0
*
* @param int $id ID of the group that is being displayed.
*/
do_action('groups_screen_group_admin_requests', $bp->groups->current_group->id);
/**
* Filters the template to load for a group's membership request page.
*
* @since 1.0.0
*
* @param string $value Path to a group's membership request template.
*/
bp_core_load_template(apply_filters('groups_template_group_admin_requests', 'groups/single/home'));
}
示例2: groups_accept_all_pending_membership_requests
/**
* Accept all pending membership requests to a group.
*
* @param int $group_id ID of the group.
*
* @return bool True on success, false on failure.
*/
function groups_accept_all_pending_membership_requests($group_id)
{
$user_ids = BP_Groups_Member::get_all_membership_request_user_ids($group_id);
if (!$user_ids) {
return false;
}
foreach ((array) $user_ids as $user_id) {
groups_accept_membership_request(false, $user_id, $group_id);
}
/**
* Fires after the acceptance of all pending membership requests to a group.
*
* @since 1.0.2
*
* @param int $group_id ID of the group whose pending memberships were accepted.
*/
do_action('groups_accept_all_pending_membership_requests', $group_id);
return true;
}
示例3: groups_accept_all_pending_membership_requests
function groups_accept_all_pending_membership_requests($group_id)
{
$user_ids = BP_Groups_Member::get_all_membership_request_user_ids($group_id);
if (!$user_ids) {
return false;
}
foreach ((array) $user_ids as $user_id) {
groups_accept_membership_request(false, $user_id, $group_id);
}
do_action('groups_accept_all_pending_membership_requests', $group_id);
return true;
}
示例4: groups_screen_group_admin_requests
/**
* Handle the display of Admin > Membership Requests.
*/
function groups_screen_group_admin_requests()
{
$bp = buddypress();
if ('membership-requests' != bp_get_group_current_admin_tab()) {
return false;
}
if (!bp_is_item_admin() || 'public' == $bp->groups->current_group->status) {
return false;
}
$request_action = (string) bp_action_variable(1);
$membership_id = (int) bp_action_variable(2);
if (!empty($request_action) && !empty($membership_id)) {
if ('accept' == $request_action && is_numeric($membership_id)) {
// Check the nonce first.
if (!check_admin_referer('groups_accept_membership_request')) {
return false;
}
// Accept the membership request
if (!groups_accept_membership_request($membership_id)) {
bp_core_add_message(__('There was an error accepting the membership request. Please try again.', 'buddypress'), 'error');
} else {
bp_core_add_message(__('Group membership request accepted', 'buddypress'));
}
} elseif ('reject' == $request_action && is_numeric($membership_id)) {
/* Check the nonce first. */
if (!check_admin_referer('groups_reject_membership_request')) {
return false;
}
// Reject the membership request
if (!groups_reject_membership_request($membership_id)) {
bp_core_add_message(__('There was an error rejecting the membership request. Please try again.', 'buddypress'), 'error');
} else {
bp_core_add_message(__('Group membership request rejected', 'buddypress'));
}
}
do_action('groups_group_request_managed', $bp->groups->current_group->id, $request_action, $membership_id);
bp_core_redirect(bp_get_group_permalink(groups_get_current_group()) . 'admin/membership-requests/');
}
do_action('groups_screen_group_admin_requests', $bp->groups->current_group->id);
bp_core_load_template(apply_filters('groups_template_group_admin_requests', 'groups/single/home'));
}
示例5: groups_screen_group_admin_requests
function groups_screen_group_admin_requests()
{
global $bp;
if (bp_is_groups_component() && bp_is_action_variable('membership-requests', 0)) {
if (!$bp->is_item_admin || 'public' == $bp->groups->current_group->status) {
return false;
}
// Remove any screen notifications
bp_core_delete_notifications_by_type(bp_loggedin_user_id(), $bp->groups->id, 'new_membership_request');
$request_action = (string) bp_action_variable(1);
$membership_id = (int) bp_action_variable(2);
if (!empty($request_action) && !empty($membership_id)) {
if ('accept' == $request_action && is_numeric($membership_id)) {
// Check the nonce first.
if (!check_admin_referer('groups_accept_membership_request')) {
return false;
}
// Accept the membership request
if (!groups_accept_membership_request($membership_id)) {
bp_core_add_message(__('There was an error accepting the membership request, please try again.', 'buddypress'), 'error');
} else {
bp_core_add_message(__('Group membership request accepted', 'buddypress'));
}
} elseif ('reject' == $request_action && is_numeric($membership_id)) {
/* Check the nonce first. */
if (!check_admin_referer('groups_reject_membership_request')) {
return false;
}
// Reject the membership request
if (!groups_reject_membership_request($membership_id)) {
bp_core_add_message(__('There was an error rejecting the membership request, please try again.', 'buddypress'), 'error');
} else {
bp_core_add_message(__('Group membership request rejected', 'buddypress'));
}
}
do_action('groups_group_request_managed', $bp->groups->current_group->id, $request_action, $membership_id);
bp_core_redirect(bp_get_group_permalink(groups_get_current_group()) . 'admin/membership-requests/');
}
do_action('groups_screen_group_admin_requests', $bp->groups->current_group->id);
bp_core_load_template(apply_filters('groups_template_group_admin_requests', 'groups/single/home'));
}
}
示例6: test_groups_accept_membership_request_by_user_id_group_id
/**
* @group groups_accept_membership_request
* @group group_membership_requests
* @group group_membership
*/
public function test_groups_accept_membership_request_by_user_id_group_id()
{
$u1 = $this->factory->user->create();
$g1 = $this->factory->group->create();
// Create membership request
groups_send_membership_request($u1, $g1);
groups_accept_membership_request(null, $u1, $g1);
// User should now be a group member
$member = groups_is_user_member($u1, $g1);
$this->assertTrue(is_numeric($member) && $member > 0);
}
示例7: groups_screen_group_admin_requests
function groups_screen_group_admin_requests()
{
global $bp, $group_obj;
if ($bp->current_component == $bp->groups->slug && 'membership-requests' == $bp->action_variables[0]) {
if (!$bp->is_item_admin || 'public' == $group_obj->status) {
return false;
}
// Remove any screen notifications
bp_core_delete_notifications_for_user_by_type($bp->loggedin_user->id, $bp->groups->slug, 'new_membership_request');
$request_action = $bp->action_variables[1];
$membership_id = $bp->action_variables[2];
if (isset($request_action) && isset($membership_id)) {
if ('accept' == $request_action && is_numeric($membership_id)) {
// Accept the membership request
if (!groups_accept_membership_request($membership_id)) {
bp_core_add_message(__('There was an error accepting the membership request, please try again.', 'buddypress'), 'error');
} else {
bp_core_add_message(__('Group membership request accepted', 'buddypress'));
}
} else {
if ('reject' == $request_action && is_numeric($membership_id)) {
// Reject the membership request
if (!groups_reject_membership_request($membership_id)) {
bp_core_add_message(__('There was an error rejecting the membership request, please try again.', 'buddypress'), 'error');
} else {
bp_core_add_message(__('Group membership request rejected', 'buddypress'));
}
}
}
do_action('groups_group_request_managed', $group_obj->id, $request_action, $membership_id);
bp_core_redirect(site_url() . '/' . $bp->current_component . '/' . $bp->current_item . '/admin/membership-requests');
}
do_action('groups_screen_group_admin_requests', $group_obj->id);
bp_core_load_template(apply_filters('groups_template_group_admin_requests', 'groups/admin/membership-requests'));
}
}
示例8: 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));
}
示例9: 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'));
}