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


PHP groups_send_invites函数代码示例

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


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

示例1: save

 function save()
 {
     global $bp;
     /* Set error redirect based on save method */
     if ($this->method == 'create') {
         $redirect_url = $bp->loggedin_user->domain . $bp->groups->slug . '/create/step/' . $this->slug;
     } else {
         $redirect_url = bp_get_group_permalink($bp->groups->current_group) . '/admin/' . $this->slug;
     }
     groups_send_invites($bp->loggedin_user->id, $bp->groups->current_group->id);
     if ($this->has_invites) {
         bp_core_add_message(__('Group invites sent.', 'buddypress'));
     } else {
         bp_core_add_message(__('Group created successfully.', 'buddypress'));
     }
 }
开发者ID:kd5ytx,项目名称:Empirical-Wordpress,代码行数:16,代码来源:group-invites.php

示例2: invite_anyone_activate_user

function invite_anyone_activate_user($user_id, $key, $user)
{
    global $bp;
    $email = bp_core_get_user_email($user_id);
    $inviters = array();
    // Fire the query
    $invites = invite_anyone_get_invitations_by_invited_email($email);
    if ($invites->have_posts()) {
        // From the posts returned by the query, get a list of unique inviters
        $groups = array();
        while ($invites->have_posts()) {
            $invites->the_post();
            $inviter_id = get_the_author_meta('ID');
            $inviters[] = $inviter_id;
            $groups_data = wp_get_post_terms(get_the_ID(), invite_anyone_get_invited_groups_tax_name());
            foreach ($groups_data as $group_data) {
                if (!isset($groups[$group_data->name])) {
                    // Keyed by inviter, which means they'll only get one invite per group
                    $groups[$group_data->name] = $inviter_id;
                }
            }
            // Mark as accepted
            update_post_meta(get_the_ID(), 'bp_ia_accepted', date('Y-m-d H:i:s'));
        }
        $inviters = array_unique($inviters);
        // Friendship requests
        if (bp_is_active('friends') && apply_filters('invite_anyone_send_friend_requests_on_acceptance', true)) {
            if (function_exists('friends_add_friend')) {
                foreach ($inviters as $inviter) {
                    friends_add_friend($inviter, $user_id);
                }
            }
        }
        // BuddyPress Followers support
        if (function_exists('bp_follow_start_following') && apply_filters('invite_anyone_send_follow_requests_on_acceptance', true)) {
            foreach ($inviters as $inviter) {
                bp_follow_start_following(array('leader_id' => $user_id, 'follower_id' => $inviter));
                bp_follow_start_following(array('leader_id' => $inviter, 'follower_id' => $user_id));
            }
        }
        // Group invitations
        if (bp_is_active('groups')) {
            foreach ($groups as $group_id => $inviter_id) {
                $args = array('user_id' => $user_id, 'group_id' => $group_id, 'inviter_id' => $inviter_id);
                groups_invite_user($args);
                groups_send_invites($inviter_id, $group_id);
            }
        }
    }
    do_action('accepted_email_invite', $user_id, $inviters);
}
开发者ID:kd5ytx,项目名称:Empirical-Wordpress,代码行数:51,代码来源:by-email.php

示例3: groups_screen_group_invite

/**
 * Handle the display of a group's Send Invites page.
 */
function groups_screen_group_invite()
{
    if (!bp_is_single_item()) {
        return false;
    }
    $bp = buddypress();
    if (bp_is_action_variable('send', 0)) {
        if (!check_admin_referer('groups_send_invites', '_wpnonce_send_invites')) {
            return false;
        }
        if (!empty($_POST['friends'])) {
            foreach ((array) $_POST['friends'] as $friend) {
                groups_invite_user(array('user_id' => $friend, 'group_id' => $bp->groups->current_group->id));
            }
        }
        // Send the invites.
        groups_send_invites(bp_loggedin_user_id(), $bp->groups->current_group->id);
        bp_core_add_message(__('Group invites sent.', 'buddypress'));
        /**
         * Fires after the sending of a group invite inside the group's Send Invites page.
         *
         * @since 1.0.0
         *
         * @param int $id ID of the group whose members are being displayed.
         */
        do_action('groups_screen_group_invite', $bp->groups->current_group->id);
        bp_core_redirect(bp_get_group_permalink($bp->groups->current_group));
    } elseif (!bp_action_variable(0)) {
        /**
         * Filters the template to load for a group's Send Invites page.
         *
         * @since 1.0.0
         *
         * @param string $value Path to a group's Send Invites template.
         */
        bp_core_load_template(apply_filters('groups_template_group_invite', 'groups/single/home'));
    } else {
        bp_do_404();
    }
}
开发者ID:swissspidy,项目名称:BuddyPress,代码行数:43,代码来源:bp-groups-screens.php

示例4: groups_action_create_group

/**
 * Catch and process group creation form submissions.
 */
function groups_action_create_group()
{
    global $bp;
    // If we're not at domain.org/groups/create/ then return false
    if (!bp_is_groups_component() || !bp_is_current_action('create')) {
        return false;
    }
    if (!is_user_logged_in()) {
        return false;
    }
    if (!bp_user_can_create_groups()) {
        bp_core_add_message(__('Sorry, you are not allowed to create groups.', 'buddypress'), 'error');
        bp_core_redirect(trailingslashit(bp_get_root_domain() . '/' . bp_get_groups_root_slug()));
    }
    // Make sure creation steps are in the right order
    groups_action_sort_creation_steps();
    // If no current step is set, reset everything so we can start a fresh group creation
    $bp->groups->current_create_step = bp_action_variable(1);
    if (!bp_get_groups_current_create_step()) {
        unset($bp->groups->current_create_step);
        unset($bp->groups->completed_create_steps);
        setcookie('bp_new_group_id', false, time() - 1000, COOKIEPATH);
        setcookie('bp_completed_create_steps', false, time() - 1000, COOKIEPATH);
        $reset_steps = true;
        $keys = array_keys($bp->groups->group_creation_steps);
        bp_core_redirect(bp_get_root_domain() . '/' . bp_get_groups_root_slug() . '/create/step/' . array_shift($keys) . '/');
    }
    // If this is a creation step that is not recognized, just redirect them back to the first screen
    if (bp_get_groups_current_create_step() && empty($bp->groups->group_creation_steps[bp_get_groups_current_create_step()])) {
        bp_core_add_message(__('There was an error saving group details. Please try again.', 'buddypress'), 'error');
        bp_core_redirect(bp_get_root_domain() . '/' . bp_get_groups_root_slug() . '/create/');
    }
    // Fetch the currently completed steps variable
    if (isset($_COOKIE['bp_completed_create_steps']) && !isset($reset_steps)) {
        $bp->groups->completed_create_steps = json_decode(base64_decode(stripslashes($_COOKIE['bp_completed_create_steps'])));
    }
    // Set the ID of the new group, if it has already been created in a previous step
    if (isset($_COOKIE['bp_new_group_id'])) {
        $bp->groups->new_group_id = (int) $_COOKIE['bp_new_group_id'];
        $bp->groups->current_group = groups_get_group(array('group_id' => $bp->groups->new_group_id));
        // Only allow the group creator to continue to edit the new group
        if (!bp_is_group_creator($bp->groups->current_group, bp_loggedin_user_id())) {
            bp_core_add_message(__('Only the group creator may continue editing this group.', 'buddypress'), 'error');
            bp_core_redirect(bp_get_root_domain() . '/' . bp_get_groups_root_slug() . '/create/');
        }
    }
    // If the save, upload or skip button is hit, lets calculate what we need to save
    if (isset($_POST['save'])) {
        // Check the nonce
        check_admin_referer('groups_create_save_' . bp_get_groups_current_create_step());
        if ('group-details' == bp_get_groups_current_create_step()) {
            if (empty($_POST['group-name']) || empty($_POST['group-desc']) || !strlen(trim($_POST['group-name'])) || !strlen(trim($_POST['group-desc']))) {
                bp_core_add_message(__('Please fill in all of the required fields', 'buddypress'), 'error');
                bp_core_redirect(bp_get_root_domain() . '/' . bp_get_groups_root_slug() . '/create/step/' . bp_get_groups_current_create_step() . '/');
            }
            $new_group_id = isset($bp->groups->new_group_id) ? $bp->groups->new_group_id : 0;
            if (!($bp->groups->new_group_id = groups_create_group(array('group_id' => $new_group_id, 'name' => $_POST['group-name'], 'description' => $_POST['group-desc'], 'slug' => groups_check_slug(sanitize_title(esc_attr($_POST['group-name']))), 'date_created' => bp_core_current_time(), 'status' => 'public')))) {
                bp_core_add_message(__('There was an error saving group details, please try again.', 'buddypress'), 'error');
                bp_core_redirect(bp_get_root_domain() . '/' . bp_get_groups_root_slug() . '/create/step/' . bp_get_groups_current_create_step() . '/');
            }
        }
        if ('group-settings' == bp_get_groups_current_create_step()) {
            $group_status = 'public';
            $group_enable_forum = 1;
            if (!isset($_POST['group-show-forum'])) {
                $group_enable_forum = 0;
            } else {
                // Create the forum if enable_forum = 1
                if (bp_is_active('forums') && !groups_get_groupmeta($bp->groups->new_group_id, 'forum_id')) {
                    groups_new_group_forum();
                }
            }
            if ('private' == $_POST['group-status']) {
                $group_status = 'private';
            } else {
                if ('hidden' == $_POST['group-status']) {
                    $group_status = 'hidden';
                }
            }
            if (!($bp->groups->new_group_id = groups_create_group(array('group_id' => $bp->groups->new_group_id, 'status' => $group_status, 'enable_forum' => $group_enable_forum)))) {
                bp_core_add_message(__('There was an error saving group details, please try again.', 'buddypress'), 'error');
                bp_core_redirect(bp_get_root_domain() . '/' . bp_get_groups_root_slug() . '/create/step/' . bp_get_groups_current_create_step() . '/');
            }
            // Set the invite status
            // Checked against a whitelist for security
            $allowed_invite_status = apply_filters('groups_allowed_invite_status', array('members', 'mods', 'admins'));
            $invite_status = !empty($_POST['group-invite-status']) && in_array($_POST['group-invite-status'], (array) $allowed_invite_status) ? $_POST['group-invite-status'] : 'members';
            groups_update_groupmeta($bp->groups->new_group_id, 'invite_status', $invite_status);
        }
        if ('group-invites' === bp_get_groups_current_create_step()) {
            if (!empty($_POST['friends'])) {
                foreach ((array) $_POST['friends'] as $friend) {
                    groups_invite_user(array('user_id' => $friend, 'group_id' => $bp->groups->new_group_id));
                }
            }
            groups_send_invites(bp_loggedin_user_id(), $bp->groups->new_group_id);
        }
//.........这里部分代码省略.........
开发者ID:eresyyl,项目名称:mk,代码行数:101,代码来源:bp-groups-actions.php

示例5: groups_screen_group_invite

/**
 * Handle the display of a group's Send Invites page.
 */
function groups_screen_group_invite()
{
    if (!bp_is_single_item()) {
        return false;
    }
    $bp = buddypress();
    if (bp_is_action_variable('send', 0)) {
        if (!check_admin_referer('groups_send_invites', '_wpnonce_send_invites')) {
            return false;
        }
        if (!empty($_POST['friends'])) {
            foreach ((array) $_POST['friends'] as $friend) {
                groups_invite_user(array('user_id' => $friend, 'group_id' => $bp->groups->current_group->id));
            }
        }
        // Send the invites.
        groups_send_invites(bp_loggedin_user_id(), $bp->groups->current_group->id);
        bp_core_add_message(__('Group invites sent.', 'buddypress'));
        do_action('groups_screen_group_invite', $bp->groups->current_group->id);
        bp_core_redirect(bp_get_group_permalink($bp->groups->current_group));
    } elseif (!bp_action_variable(0)) {
        // Show send invite page
        bp_core_load_template(apply_filters('groups_template_group_invite', 'groups/single/home'));
    } else {
        bp_do_404();
    }
}
开发者ID:sdh100shaun,项目名称:pantheon,代码行数:30,代码来源:bp-groups-screens.php

示例6: groups_action_create_group

function groups_action_create_group() {
	global $bp;

	/* If we're not at domain.org/groups/create/ then return false */
	if ( $bp->current_component != $bp->groups->slug || 'create' != $bp->current_action )
		return false;

	if ( !is_user_logged_in() )
		return false;

	/* Make sure creation steps are in the right order */
	groups_action_sort_creation_steps();

	/* If no current step is set, reset everything so we can start a fresh group creation */
	if ( !$bp->groups->current_create_step = $bp->action_variables[1] ) {

		unset( $bp->groups->current_create_step );
		unset( $bp->groups->completed_create_steps );

		setcookie( 'bp_new_group_id', false, time() - 1000, COOKIEPATH );
		setcookie( 'bp_completed_create_steps', false, time() - 1000, COOKIEPATH );

		$reset_steps = true;
		bp_core_redirect( $bp->root_domain . '/' . $bp->groups->slug . '/create/step/' . array_shift( array_keys( $bp->groups->group_creation_steps ) ) . '/' );
	}

	/* If this is a creation step that is not recognized, just redirect them back to the first screen */
	if ( $bp->action_variables[1] && !$bp->groups->group_creation_steps[$bp->action_variables[1]] ) {
		bp_core_add_message( __('There was an error saving group details. Please try again.', 'buddypress'), 'error' );
		bp_core_redirect( $bp->root_domain . '/' . $bp->groups->slug . '/create/' );
	}

	/* Fetch the currently completed steps variable */
	if ( isset( $_COOKIE['bp_completed_create_steps'] ) && !$reset_steps )
		$bp->groups->completed_create_steps = unserialize( stripslashes( $_COOKIE['bp_completed_create_steps'] ) );

	/* Set the ID of the new group, if it has already been created in a previous step */
	if ( isset( $_COOKIE['bp_new_group_id'] ) ) {
		$bp->groups->new_group_id = $_COOKIE['bp_new_group_id'];
		$bp->groups->current_group = new BP_Groups_Group( $bp->groups->new_group_id );
	}

	/* If the save, upload or skip button is hit, lets calculate what we need to save */
	if ( isset( $_POST['save'] ) ) {

		/* Check the nonce */
		check_admin_referer( 'groups_create_save_' . $bp->groups->current_create_step );

		if ( 'group-details' == $bp->groups->current_create_step ) {
			if ( empty( $_POST['group-name'] ) || empty( $_POST['group-desc'] ) || !strlen( trim( $_POST['group-name'] ) ) || !strlen( trim( $_POST['group-desc'] ) ) ) {
				bp_core_add_message( __( 'Please fill in all of the required fields', 'buddypress' ), 'error' );
				bp_core_redirect( $bp->root_domain . '/' . $bp->groups->slug . '/create/step/' . $bp->groups->current_create_step . '/' );
			}

			if ( !$bp->groups->new_group_id = groups_create_group( array( 'group_id' => $bp->groups->new_group_id, 'name' => $_POST['group-name'], 'description' => $_POST['group-desc'], 'slug' => groups_check_slug( sanitize_title( esc_attr( $_POST['group-name'] ) ) ), 'date_created' => gmdate( "Y-m-d H:i:s" ), 'status' => 'public' ) ) ) {
				bp_core_add_message( __( 'There was an error saving group details, please try again.', 'buddypress' ), 'error' );
				bp_core_redirect( $bp->root_domain . '/' . $bp->groups->slug . '/create/step/' . $bp->groups->current_create_step . '/' );
			}

			groups_update_groupmeta( $bp->groups->new_group_id, 'total_member_count', 1 );
			groups_update_groupmeta( $bp->groups->new_group_id, 'last_activity', gmdate( "Y-m-d H:i:s" ) );
		}

		if ( 'group-settings' == $bp->groups->current_create_step ) {
			$group_status = 'public';
			$group_enable_forum = 1;

			if ( !isset($_POST['group-show-forum']) ) {
				$group_enable_forum = 0;
			} else {
				/* Create the forum if enable_forum = 1 */
				if ( function_exists( 'bp_forums_setup' ) && '' == groups_get_groupmeta( $bp->groups->new_group_id, 'forum_id' ) ) {
					groups_new_group_forum();
				}
			}

			if ( 'private' == $_POST['group-status'] )
				$group_status = 'private';
			else if ( 'hidden' == $_POST['group-status'] )
				$group_status = 'hidden';

			if ( !$bp->groups->new_group_id = groups_create_group( array( 'group_id' => $bp->groups->new_group_id, 'status' => $group_status, 'enable_forum' => $group_enable_forum ) ) ) {
				bp_core_add_message( __( 'There was an error saving group details, please try again.', 'buddypress' ), 'error' );
				bp_core_redirect( $bp->root_domain . '/' . $bp->groups->slug . '/create/step/' . $bp->groups->current_create_step . '/' );
			}
		}

		if ( 'group-invites' == $bp->groups->current_create_step ) {
			groups_send_invites( $bp->loggedin_user->id, $bp->groups->new_group_id );
		}

		do_action( 'groups_create_group_step_save_' . $bp->groups->current_create_step );
		do_action( 'groups_create_group_step_complete' ); // Mostly for clearing cache on a generic action name

		/**
		 * Once we have successfully saved the details for this step of the creation process
		 * we need to add the current step to the array of completed steps, then update the cookies
		 * holding the information
		 */
		if ( !in_array( $bp->groups->current_create_step, (array)$bp->groups->completed_create_steps ) )
//.........这里部分代码省略.........
开发者ID:n-sane,项目名称:zaroka,代码行数:101,代码来源:bp-groups.php

示例7: test_groups_membership_request_plus_invite_equals_member

 /**
  * @group groups_send_invites
  * @group group_invitations
  * @group group_membership_requests
  * @group group_membership
  */
 public function test_groups_membership_request_plus_invite_equals_member()
 {
     $u1 = $this->factory->user->create();
     $u2 = $this->factory->user->create();
     $g1 = $this->factory->group->create(array('creator_id' => $u1));
     // Create membership request
     groups_send_membership_request($u2, $g1);
     // 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));
     // Send the invitation
     groups_send_invites($u1, $g1);
     // User should now be a group member
     $member = groups_is_user_member($u2, $g1);
     $this->assertTrue(is_numeric($member) && $member > 0);
 }
开发者ID:jasonmcalpin,项目名称:BuddyPress,代码行数:21,代码来源:class-bp-groups-member.php

示例8: groups_create_group


//.........这里部分代码省略.........
                    $group_obj->photos_admin_only = 0;
                    $group_obj->date_created = time();
                    if (!$group_obj->save()) {
                        return false;
                    }
                    // Save the creator as the group administrator
                    $admin = new BP_Groups_Member($bp->loggedin_user->id, $group_obj->id);
                    $admin->is_admin = 1;
                    $admin->user_title = __('Group Admin', 'buddypress');
                    $admin->date_modified = time();
                    $admin->inviter_id = 0;
                    $admin->is_confirmed = 1;
                    if (!$admin->save()) {
                        return false;
                    }
                    do_action('groups_create_group_step1_save');
                    /* Set groupmeta */
                    groups_update_groupmeta($group_obj->id, 'total_member_count', 1);
                    groups_update_groupmeta($group_obj->id, 'last_activity', time());
                    groups_update_groupmeta($group_obj->id, 'theme', 'buddypress');
                    groups_update_groupmeta($group_obj->id, 'stylesheet', 'buddypress');
                    return $group_obj->id;
                }
                return false;
                break;
            case '2':
                if (!check_admin_referer('groups_step2_save')) {
                    return false;
                }
                $group_obj->status = 'public';
                $group_obj->is_invitation_only = 0;
                $group_obj->enable_wire = 1;
                $group_obj->enable_forum = 1;
                $group_obj->enable_photos = 1;
                $group_obj->photos_admin_only = 0;
                if (!isset($_POST['group-show-wire'])) {
                    $group_obj->enable_wire = 0;
                }
                if (!isset($_POST['group-show-forum'])) {
                    $group_obj->enable_forum = 0;
                } else {
                    /* Create the forum if enable_forum = 1 */
                    if (function_exists('bp_forums_setup') && '' == groups_get_groupmeta($group_obj->id, 'forum_id')) {
                        groups_new_group_forum();
                    }
                }
                if (!isset($_POST['group-show-photos'])) {
                    $group_obj->enable_photos = 0;
                }
                if ($_POST['group-photos-status'] != 'all') {
                    $group_obj->photos_admin_only = 1;
                }
                if ('private' == $_POST['group-status']) {
                    $group_obj->status = 'private';
                } else {
                    if ('hidden' == $_POST['group-status']) {
                        $group_obj->status = 'hidden';
                    }
                }
                if (!$group_obj->save()) {
                    return false;
                }
                /* Record in activity streams */
                groups_record_activity(array('item_id' => $group_obj->id, 'component_name' => $bp->groups->slug, 'component_action' => 'created_group', 'is_private' => 0));
                do_action('groups_create_group_step2_save');
                return $group_obj->id;
                break;
            case '3':
                if (!check_admin_referer('groups_step3_save')) {
                    return false;
                }
                if (isset($_POST['skip'])) {
                    return $group_obj->id;
                }
                // Image already cropped and uploaded, lets store a reference in the DB.
                if (!wp_verify_nonce($_POST['nonce'], 'slick_avatars') || !($result = bp_core_avatar_cropstore($_POST['orig'], $_POST['canvas'], $_POST['v1_x1'], $_POST['v1_y1'], $_POST['v1_w'], $_POST['v1_h'], $_POST['v2_x1'], $_POST['v2_y1'], $_POST['v2_w'], $_POST['v2_h'], false, 'groupavatar', $group_obj->id))) {
                    return false;
                }
                // Success on group avatar cropping, now save the results.
                $avatar_hrefs = groups_get_avatar_hrefs($result);
                $group_obj->avatar_thumb = stripslashes($avatar_hrefs['thumb_href']);
                $group_obj->avatar_full = stripslashes($avatar_hrefs['full_href']);
                if (!$group_obj->save()) {
                    return false;
                }
                do_action('groups_create_group_step3_save');
                return $group_obj->id;
                break;
            case '4':
                if (!check_admin_referer('groups_step4_save')) {
                    return false;
                }
                groups_send_invites($group_obj, true);
                do_action('groups_created_group', $group_obj->id);
                return $group_obj->id;
                break;
        }
    }
    return false;
}
开发者ID:alvaropereyra,项目名称:shrekcms,代码行数:101,代码来源:bp-groups.php

示例9: save

 function save($group_id = null)
 {
     global $bp;
     if (null === $group_id) {
         $group_id = bp_get_current_group_id();
     }
     /* Set error redirect based on save method */
     if ($this->method == 'create') {
         $redirect_url = $bp->loggedin_user->domain . $bp->groups->slug . '/create/step/' . $this->slug;
     } else {
         $group = groups_get_group(array('group_id' => $group_id));
         $redirect_url = bp_get_group_permalink($group) . '/admin/' . $this->slug;
     }
     groups_send_invites($bp->loggedin_user->id, $group_id);
     if ($this->has_invites) {
         bp_core_add_message(__('Group invites sent.', 'invite-anyone'));
     } else {
         bp_core_add_message(__('Group created successfully.', 'invite-anyone'));
     }
 }
开发者ID:socialray,项目名称:surfied-2-0,代码行数:20,代码来源:group-invites.php

示例10: invite_anyone_activate_user

function invite_anyone_activate_user($user_id, $key, $user)
{
    global $bp;
    $email = bp_core_get_user_email($user_id);
    if ($invites = invite_anyone_get_invitations_by_invited_email($email)) {
        // Mark as "is_joined"
        invite_anyone_mark_as_joined($email);
        // Friendship requests
        if (bp_is_active('friends')) {
            $inviters = array();
            foreach ($invites as $invite) {
                if (!in_array($invite->inviter_id, $inviters)) {
                    $inviters[] = $invite->inviter_id;
                }
            }
            if (function_exists('friends_add_friend')) {
                foreach ($inviters as $inviter) {
                    friends_add_friend($inviter, $user_id);
                }
            }
        }
        // BuddyPress Followers support
        if (function_exists('bp_follow_start_following')) {
            $inviters = array();
            foreach ($invites as $invite) {
                if (!in_array($invite->inviter_id, $inviters)) {
                    $inviters[] = $invite->inviter_id;
                }
            }
            foreach ($inviters as $inviter) {
                bp_follow_start_following(array('leader_id' => $user_id, 'follower_id' => $inviter));
                bp_follow_start_following(array('leader_id' => $inviter, 'follower_id' => $user_id));
            }
        }
        // BuddyPress Followers support
        if (function_exists('bp_follow_start_following')) {
            $inviters = array();
            foreach ($invites as $invite) {
                if (!in_array($invite->inviter_id, $inviters)) {
                    $inviters[] = $invite->inviter_id;
                }
            }
            foreach ($inviters as $inviter) {
                bp_follow_start_following(array('leader_id' => $user_id, 'follower_id' => $inviter));
                bp_follow_start_following(array('leader_id' => $inviter, 'follower_id' => $user_id));
            }
        }
        // Group invitations
        if (bp_is_active('groups')) {
            $groups = array();
            foreach ($invites as $invite) {
                if (!$invite->group_invitations[0]) {
                    continue;
                } else {
                    $group_invitations = unserialize($invite->group_invitations);
                }
                foreach ($group_invitations as $group) {
                    if (!in_array($group, array_keys($groups))) {
                        $groups[$group] = $invite->inviter_id;
                    }
                }
            }
            foreach ($groups as $group_id => $inviter_id) {
                $args = array('user_id' => $user_id, 'group_id' => $group_id, 'inviter_id' => $inviter_id);
                groups_invite_user($args);
                groups_send_invites($inviter_id, $group_id);
            }
        }
    }
    do_action('accepted_email_invite', $user_id, $inviters);
}
开发者ID:hnla,项目名称:invite-anyone,代码行数:71,代码来源:by-email.php

示例11: user_activated

 /**
  * The main workhorse where the friends, groups and welcome message features happens.
  * Triggers when a user account is activated.
  *
  * @param int $user_id ID of the new user
  * @since 3.0
  */
 function user_activated($user_id)
 {
     $settings = DP_Welcome_Pack::get_settings();
     // Is the Friend invitations component enabled?
     if (!empty($settings['dpw_friendstoggle']) && bp_is_active('friends') && !empty($settings['friends'])) {
         // Send friend requests
         foreach ((array) $settings['friends'] as $friend_id) {
             friends_add_friend((int) $friend_id, $user_id, constant('WELCOME_PACK_AUTOACCEPT_INVITATIONS'));
         }
     }
     // Is the Group invitations component enabled?
     if (!empty($settings['dpw_groupstoggle']) && bp_is_active('groups') && !empty($settings['groups'])) {
         foreach ((array) $settings['groups'] as $group_id) {
             $group = new BP_Groups_Group((int) $group_id);
             // Send group invites
             groups_invite_user(array('user_id' => $user_id, 'group_id' => (int) $group_id, 'inviter_id' => $group->creator_id, 'is_confirmed' => constant('WELCOME_PACK_AUTOACCEPT_INVITATIONS')));
             groups_send_invites($group->creator_id, (int) $group_id);
         }
     }
     // Is the Welcome Message component enabled?
     if (!empty($settings['dpw_welcomemsgtoggle']) && bp_is_active('messages') && !empty($settings['welcomemsgsender']) && !empty($settings['welcomemsgsubject']) && !empty($settings['welcomemsg'])) {
         messages_new_message(array('sender_id' => $settings['welcomemsgsender'], 'recipients' => $user_id, 'subject' => apply_filters('dpw_keyword_replacement', $settings['welcomemsgsubject'], $user_id), 'content' => apply_filters('dpw_keyword_replacement', $settings['welcomemsg'], $user_id)));
     }
     // Call an action for third-parties to hook into
     do_action('dpw_user_activated', $user_id);
 }
开发者ID:hscale,项目名称:webento,代码行数:33,代码来源:welcome-pack.php

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


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