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


PHP groups_accept_invite函数代码示例

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


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

示例1: automatic_group_membership

/**
 * Automatically adds members to group 7 when they are registered
 */
function automatic_group_membership($user_id)
{
    if (!$user_id) {
        return false;
    }
    groups_accept_invite($user_id, 7);
}
开发者ID:adisonc,项目名称:MaineLearning,代码行数:10,代码来源:functions.php

示例2: groups_screen_group_invites

function groups_screen_group_invites()
{
    $group_id = (int) bp_action_variable(1);
    if (bp_is_action_variable('accept') && is_numeric($group_id)) {
        // Check the nonce
        if (!check_admin_referer('groups_accept_invite')) {
            return false;
        }
        if (!groups_accept_invite(bp_loggedin_user_id(), $group_id)) {
            bp_core_add_message(__('Group invite could not be accepted', 'buddypress'), 'error');
        } else {
            bp_core_add_message(__('Group invite accepted', 'buddypress'));
            // Record this in activity streams
            $group = new BP_Groups_Group($group_id);
            groups_record_activity(array('action' => apply_filters_ref_array('groups_activity_accepted_invite_action', array(sprintf(__('%1$s joined the group %2$s', 'buddypress'), bp_core_get_userlink(bp_loggedin_user_id()), '<a href="' . bp_get_group_permalink($group) . '">' . esc_attr($group->name) . '</a>'), bp_loggedin_user_id(), &$group)), 'type' => 'joined_group', 'item_id' => $group->id));
        }
        bp_core_redirect(bp_loggedin_user_domain() . bp_get_groups_slug() . '/' . bp_current_action());
    } else {
        if (bp_is_action_variable('reject') && is_numeric($group_id)) {
            // Check the nonce
            if (!check_admin_referer('groups_reject_invite')) {
                return false;
            }
            if (!groups_reject_invite(bp_loggedin_user_id(), $group_id)) {
                bp_core_add_message(__('Group invite could not be rejected', 'buddypress'), 'error');
            } else {
                bp_core_add_message(__('Group invite rejected', 'buddypress'));
            }
            bp_core_redirect(bp_loggedin_user_domain() . bp_get_groups_slug() . '/' . bp_current_action());
        }
    }
    // Remove notifications
    bp_core_delete_notifications_by_type(bp_loggedin_user_id(), 'groups', 'group_invite');
    do_action('groups_screen_group_invites', $group_id);
    bp_core_load_template(apply_filters('groups_template_group_invites', 'members/single/home'));
}
开发者ID:newington,项目名称:buddypress,代码行数:36,代码来源:bp-groups-screens.php

示例3: groups_send_membership_request

/**
 * Create a group membership request.
 *
 * @param int $requesting_user_id ID of the user requesting membership.
 * @param int $group_id           ID of the group.
 *
 * @return bool True on success, false on failure.
 */
function groups_send_membership_request($requesting_user_id, $group_id)
{
    // Prevent duplicate requests
    if (groups_check_for_membership_request($requesting_user_id, $group_id)) {
        return false;
    }
    // Check if the user is already a member or is banned
    if (groups_is_user_member($requesting_user_id, $group_id) || groups_is_user_banned($requesting_user_id, $group_id)) {
        return false;
    }
    // Check if the user is already invited - if so, simply accept invite
    if (groups_check_user_has_invite($requesting_user_id, $group_id)) {
        groups_accept_invite($requesting_user_id, $group_id);
        return true;
    }
    $requesting_user = new BP_Groups_Member();
    $requesting_user->group_id = $group_id;
    $requesting_user->user_id = $requesting_user_id;
    $requesting_user->inviter_id = 0;
    $requesting_user->is_admin = 0;
    $requesting_user->user_title = '';
    $requesting_user->date_modified = bp_core_current_time();
    $requesting_user->is_confirmed = 0;
    $requesting_user->comments = isset($_POST['group-request-membership-comments']) ? $_POST['group-request-membership-comments'] : '';
    if ($requesting_user->save()) {
        $admins = groups_get_group_admins($group_id);
        // Saved okay, now send the email notification
        for ($i = 0, $count = count($admins); $i < $count; ++$i) {
            groups_notification_new_membership_request($requesting_user_id, $admins[$i]->user_id, $group_id, $requesting_user->id);
        }
        /**
         * Fires after the creation of a new membership request.
         *
         * @since 1.0.0
         *
         * @param int   $requesting_user_id  ID of the user requesting membership.
         * @param array $admins              Array of group admins.
         * @param int   $group_id            ID of the group being requested to.
         * @param int   $requesting_user->id ID of the user requesting membership.
         */
        do_action('groups_membership_requested', $requesting_user_id, $admins, $group_id, $requesting_user->id);
        return true;
    }
    return false;
}
开发者ID:jasonmcalpin,项目名称:BuddyPress,代码行数:53,代码来源:bp-groups-functions.php

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

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

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

 function automatic_group_membership($user_id)
 {
     echo absint($user_id);
     if (!$user_id) {
         return false;
     }
     groups_accept_invite(3, 2);
 }
开发者ID:rauleonel,项目名称:soncursos,代码行数:8,代码来源:functions.php

示例8: test_groups_accept_invite_removes_membership_requests

 /**
  * @group groups_accept_invite
  * @group group_invitations
  * @group group_membership
  */
 public function test_groups_accept_invite_removes_membership_requests()
 {
     $u1 = $this->factory->user->create();
     $u2 = $this->factory->user->create();
     $g1 = $this->factory->group->create(array('creator_id' => $u1));
     // Create draft invitation
     groups_invite_user(array('user_id' => $u2, 'group_id' => $g1, 'inviter_id' => $u1, 'date_modified' => bp_core_current_time(), 'is_confirmed' => 0));
     // Create membership request
     groups_send_membership_request($u2, $g1);
     $request = groups_check_for_membership_request($u2, $g1);
     $this->assertTrue(is_numeric($request) && $request > 0);
     // Send the invitation
     groups_send_invites($u1, $g1);
     // Accept the invitation
     groups_accept_invite($u2, $g1);
     // Check that the membership request has been removed.
     $this->assertTrue(0 == groups_check_for_membership_request($u2, $g1));
 }
开发者ID:jasonmcalpin,项目名称:BuddyPress,代码行数:23,代码来源:class-bp-groups-member.php

示例9: groups_screen_group_invites

function groups_screen_group_invites() {
	global $bp;

	$group_id = $bp->action_variables[1];

	if ( isset($bp->action_variables) && in_array( 'accept', (array)$bp->action_variables ) && is_numeric($group_id) ) {
		/* Check the nonce */
		if ( !check_admin_referer( 'groups_accept_invite' ) )
			return false;

		if ( !groups_accept_invite( $bp->loggedin_user->id, $group_id ) ) {
			bp_core_add_message( __('Group invite could not be accepted', 'buddypress'), 'error' );
		} else {
			bp_core_add_message( __('Group invite accepted', 'buddypress') );

			/* Record this in activity streams */
			$group = new BP_Groups_Group( $group_id );

			groups_record_activity( array(
				'action' => apply_filters( 'groups_activity_accepted_invite_action', sprintf( __( '%s joined the group %s', 'buddypress'), bp_core_get_userlink( $bp->loggedin_user->id ), '<a href="' . bp_get_group_permalink( $group ) . '">' . esc_attr( $group->name ) . '</a>' ), $bp->loggedin_user->id, &$group ),
				'type' => 'joined_group',
				'item_id' => $group->id
			) );
		}

		bp_core_redirect( $bp->loggedin_user->domain . $bp->current_component . '/' . $bp->current_action );

	} else if ( isset($bp->action_variables) && in_array( 'reject', (array)$bp->action_variables ) && is_numeric($group_id) ) {
		/* Check the nonce */
		if ( !check_admin_referer( 'groups_reject_invite' ) )
			return false;

		if ( !groups_reject_invite( $bp->loggedin_user->id, $group_id ) ) {
			bp_core_add_message( __('Group invite could not be rejected', 'buddypress'), 'error' );
		} else {
			bp_core_add_message( __('Group invite rejected', 'buddypress') );
		}

		bp_core_redirect( $bp->loggedin_user->domain . $bp->current_component . '/' . $bp->current_action );
	}

	// Remove notifications
	bp_core_delete_notifications_for_user_by_type( $bp->loggedin_user->id, $bp->groups->id, 'group_invite' );

	do_action( 'groups_screen_group_invites', $group_id );

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

示例10: groups_screen_group_invites

function groups_screen_group_invites()
{
    global $bp;
    $group_id = $bp->action_variables[1];
    if (isset($bp->action_variables) && in_array('accept', $bp->action_variables) && is_numeric($group_id)) {
        if (!groups_accept_invite($bp->loggedin_user->id, $group_id)) {
            bp_core_add_message(__('Group invite could not be accepted', 'buddypress'), 'error');
        } else {
            bp_core_add_message(__('Group invite accepted', 'buddypress'));
            /* Record this in activity streams */
            groups_record_activity(array('item_id' => $group_id, 'component_name' => $bp->groups->slug, 'component_action' => 'joined_group', 'is_private' => 0));
        }
        bp_core_redirect($bp->loggedin_user->domain . $bp->current_component . '/' . $bp->current_action);
    } else {
        if (isset($bp->action_variables) && in_array('reject', $bp->action_variables) && is_numeric($group_id)) {
            if (!groups_reject_invite($bp->loggedin_user->id, $group_id)) {
                bp_core_add_message(__('Group invite could not be rejected', 'buddypress'), 'error');
            } else {
                bp_core_add_message(__('Group invite rejected', 'buddypress'));
            }
            bp_core_redirect($bp->loggedin_user->domain . $bp->current_component . '/' . $bp->current_action);
        }
    }
    // Remove notifications
    bp_core_delete_notifications_for_user_by_type($bp->loggedin_user->id, $bp->groups->slug, 'group_invite');
    do_action('groups_screen_group_invites', $group_id);
    bp_core_load_template(apply_filters('groups_template_group_invites', 'groups/list-invites'));
}
开发者ID:alvaropereyra,项目名称:shrekcms,代码行数:28,代码来源:bp-groups.php

示例11: test_cache_should_be_invalidated_on_group_invite_acceptance

 /**
  * @group cache
  */
 public function test_cache_should_be_invalidated_on_group_invite_acceptance()
 {
     groups_invite_user(array('user_id' => self::$user, 'group_id' => self::$groups[2], 'inviter_id' => self::$admin_user));
     // Populate cache.
     $g1 = bp_get_user_groups(self::$user);
     groups_accept_invite(self::$user, self::$groups[2]);
     $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,代码行数:13,代码来源:bpGetUserGroups.php

示例12: auto_join_group

 function auto_join_group($event_id, $user_id)
 {
     if (!function_exists('groups_get_groups')) {
         return false;
     }
     if (!$this->_data->get_option('bp-group_event-auto_join_groups')) {
         return false;
     }
     $group_id = (int) get_post_meta($event_id, 'eab_event-bp-group_event', true);
     if (!$group_id) {
         return false;
     }
     groups_accept_invite($user_id, $group_id);
 }
开发者ID:nayabbukhari,项目名称:circulocristiano,代码行数:14,代码来源:eab-buddypress-group_events.php

示例13: test_get_invite_count_for_user

 /**
  * @group counts
  */
 public function test_get_invite_count_for_user()
 {
     $u1 = $this->factory->user->create();
     $u2 = $this->factory->user->create();
     $g = $this->factory->group->create(array('creator_id' => $u1));
     // create invitation
     groups_invite_user(array('user_id' => $u2, 'group_id' => $g, 'inviter_id' => $u1));
     // send the invite
     // this function is imperative to set the 'invite_sent' flag in the DB
     // why is this separated from groups_invite_user()?
     // @see groups_screen_group_invite()
     groups_send_invites($u1, $g);
     // assert invite count
     $this->assertEquals(1, groups_get_invite_count_for_user($u2));
     // accept the invite and reassert
     groups_accept_invite($u2, $g);
     $this->assertEquals(0, groups_get_invite_count_for_user($u2));
 }
开发者ID:CompositeUK,项目名称:clone.BuddyPress,代码行数:21,代码来源:functions.php

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