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


PHP BP_Groups_Member类代码示例

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


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

示例1: test_group_access_test_friends

 /**
  * @group invite_anyone_group_invite_access_test
  *
  * Using this as a proxy for testing every possible combination
  */
 public function test_group_access_test_friends()
 {
     $settings = bp_get_option('invite_anyone');
     bp_update_option('invite_anyone', array('group_invites_can_admin' => 'friends', 'group_invites_can_group_admin' => 'friends', 'group_invites_can_group_mod' => 'friends', 'group_invites_can_group_member' => 'friends'));
     unset($GLOBALS['iaoptions']);
     $g = $this->factory->group->create();
     $u1 = $this->factory->user->create(array('role' => 'administrator'));
     $this->add_user_to_group($u1, $g);
     $u2 = $this->factory->user->create();
     $this->add_user_to_group($u2, $g);
     $u3 = $this->factory->user->create();
     $this->add_user_to_group($u3, $g);
     $m3 = new BP_Groups_Member($u3, $g);
     $m3->promote('mod');
     $u4 = $this->factory->user->create();
     $this->add_user_to_group($u4, $g);
     $m4 = new BP_Groups_Member($u4, $g);
     $m4->promote('admin');
     $user = new WP_User($u1);
     $this->assertSame('friends', invite_anyone_group_invite_access_test($g, $u1));
     $this->assertSame('friends', invite_anyone_group_invite_access_test($g, $u2));
     $this->assertSame('friends', invite_anyone_group_invite_access_test($g, $u3));
     $this->assertSame('friends', invite_anyone_group_invite_access_test($g, $u4));
     bp_update_option('invite_anyone', $settings);
 }
开发者ID:socialray,项目名称:surfied-2-0,代码行数:30,代码来源:test-sample.php

示例2: groups_notification_group_updated

function groups_notification_group_updated($group_id)
{
    global $bp;
    $group = new BP_Groups_Group($group_id);
    $sitename = wp_specialchars_decode(get_blog_option(bp_get_root_blog_id(), 'blogname'), ENT_QUOTES);
    $subject = '[' . $sitename . '] ' . __('Group Details Updated', 'buddypress');
    $user_ids = BP_Groups_Member::get_group_member_ids($group->id);
    foreach ((array) $user_ids as $user_id) {
        if ('no' == bp_get_user_meta($user_id, 'notification_groups_group_updated', true)) {
            continue;
        }
        $ud = bp_core_get_core_userdata($user_id);
        // Set up and send the message
        $to = $ud->user_email;
        $group_link = site_url(bp_get_groups_root_slug() . '/' . $group->slug);
        $settings_slug = function_exists('bp_get_settings_slug') ? bp_get_settings_slug() : 'settings';
        $settings_link = bp_core_get_user_domain($user_id) . $settings_slug . '/notifications/';
        $message = sprintf(__('Group details for the group "%1$s" were updated:

To view the group: %2$s

---------------------
', 'buddypress'), $group->name, $group_link);
        $message .= sprintf(__('To disable these notifications please log in and go to: %s', 'buddypress'), $settings_link);
        /* Send the message */
        $to = apply_filters('groups_notification_group_updated_to', $to);
        $subject = apply_filters_ref_array('groups_notification_group_updated_subject', array($subject, &$group));
        $message = apply_filters_ref_array('groups_notification_group_updated_message', array($message, &$group, $group_link, $settings_link));
        wp_mail($to, $subject, $message);
        unset($message, $to);
    }
    do_action('bp_groups_sent_updated_email', $user_ids, $subject, '', $group_id);
}
开发者ID:newington,项目名称:buddypress,代码行数:33,代码来源:bp-groups-notifications.php

示例3: groups_notification_group_updated

function groups_notification_group_updated($group_id)
{
    $group = groups_get_group(array('group_id' => $group_id));
    $subject = bp_get_email_subject(array('text' => __('Group Details Updated', 'buddypress')));
    $user_ids = BP_Groups_Member::get_group_member_ids($group->id);
    foreach ((array) $user_ids as $user_id) {
        if ('no' == bp_get_user_meta($user_id, 'notification_groups_group_updated', true)) {
            continue;
        }
        $ud = bp_core_get_core_userdata($user_id);
        // Set up and send the message
        $to = $ud->user_email;
        $group_link = bp_get_group_permalink($group);
        $settings_slug = function_exists('bp_get_settings_slug') ? bp_get_settings_slug() : 'settings';
        $settings_link = bp_core_get_user_domain($user_id) . $settings_slug . '/notifications/';
        $message = sprintf(__('Group details for the group "%1$s" were updated:

To view the group: %2$s

---------------------
', 'buddypress'), $group->name, $group_link);
        $message .= sprintf(__('To disable these notifications please log in and go to: %s', 'buddypress'), $settings_link);
        /* Send the message */
        $to = apply_filters('groups_notification_group_updated_to', $to);
        $subject = apply_filters_ref_array('groups_notification_group_updated_subject', array($subject, &$group));
        $message = apply_filters_ref_array('groups_notification_group_updated_message', array($message, &$group, $group_link, $settings_link));
        wp_mail($to, $subject, $message);
        unset($message, $to);
    }
    do_action('bp_groups_sent_updated_email', $user_ids, $subject, '', $group_id);
}
开发者ID:pyropictures,项目名称:wordpress-plugins,代码行数:31,代码来源:bp-groups-notifications.php

示例4: set_up_user_groups

 /**
  * Get a list of a user's groups, as well as those groups of which
  * the user is an admin or mod
  *
  * @since 1.2
  */
 protected function set_up_user_groups()
 {
     $groups = BP_Groups_Member::get_group_ids($this->user_id);
     $this->user_groups['groups'] = $groups['groups'];
     $admin_groups = BP_Groups_Member::get_is_admin_of($this->user_id);
     $mod_groups = BP_Groups_Member::get_is_mod_of($this->user_id);
     $this->user_groups['admin_mod_of'] = array_merge(wp_list_pluck($admin_groups['groups'], 'id'), wp_list_pluck($mod_groups['groups'], 'id'));
 }
开发者ID:adisonc,项目名称:MaineLearning,代码行数:14,代码来源:access-query.php

示例5: user_member_ids

 public function user_member_ids()
 {
     if (is_null($this->_user_members)) {
         if (self::owner_type_group == $this->owner_type) {
             $this->_user_members = (array) BP_Groups_Member::get_group_member_ids($this->owner_id);
         } else {
             $this->_user_members = array($this->owner_id);
         }
     }
     return $this->_user_members;
 }
开发者ID:jeffryevans,项目名称:biblefox-wp,代码行数:11,代码来源:plan.php

示例6: groups_notification_group_updated

/**
 * Notify all group members when a group is updated.
 *
 * @since BuddyPress (1.0.0)
 *
 * @param int $group_id ID of the group.
 * @param BP_Groups_Group $old_group Group before new details were saved.
 */
function groups_notification_group_updated($group_id = 0, $old_group = null)
{
    $group = groups_get_group(array('group_id' => $group_id));
    if ($old_group instanceof BP_Groups_Group) {
        $changed = array();
        if ($group->name !== $old_group->name) {
            $changed[] = sprintf(_x('* Name changed from "%s" to "%s"', 'Group update email text', 'buddypress'), esc_html($old_group->name), esc_html($group->name));
        }
        if ($group->description !== $old_group->description) {
            $changed[] = sprintf(_x('* Description changed from "%s" to "%s"', 'Group update email text', 'buddypress'), esc_html($old_group->description), esc_html($group->description));
        }
    }
    /**
     * Filters the bullet points listing updated items in the email notification after a group is updated.
     *
     * @since BuddyPress (2.2.0)
     *
     * @param array $changed Array of bullet points.
     */
    $changed = apply_filters('groups_notification_group_update_updated_items', $changed);
    $changed_text = '';
    if (!empty($changed)) {
        $changed_text = "\n\n" . implode("\n", $changed);
    }
    $subject = bp_get_email_subject(array('text' => __('Group Details Updated', 'buddypress')));
    $user_ids = BP_Groups_Member::get_group_member_ids($group->id);
    foreach ((array) $user_ids as $user_id) {
        // Continue if member opted out of receiving this email
        if ('no' === bp_get_user_meta($user_id, 'notification_groups_group_updated', true)) {
            continue;
        }
        $ud = bp_core_get_core_userdata($user_id);
        // Set up and send the message
        $to = $ud->user_email;
        $group_link = bp_get_group_permalink($group);
        $settings_slug = function_exists('bp_get_settings_slug') ? bp_get_settings_slug() : 'settings';
        $settings_link = bp_core_get_user_domain($user_id) . $settings_slug . '/notifications/';
        $message = sprintf(__('Group details for the group "%1$s" were updated: %2$s

To view the group: %3$s

---------------------
', 'buddypress'), $group->name, $changed_text, $group_link);
        $message .= sprintf(__('To disable these notifications please log in and go to: %s', 'buddypress'), $settings_link);
        /* Send the message */
        $to = apply_filters('groups_notification_group_updated_to', $to);
        $subject = apply_filters_ref_array('groups_notification_group_updated_subject', array($subject, &$group));
        $message = apply_filters_ref_array('groups_notification_group_updated_message', array($message, &$group, $group_link, $settings_link));
        wp_mail($to, $subject, $message);
        unset($message, $to);
    }
    do_action('bp_groups_sent_updated_email', $user_ids, $subject, '', $group_id);
}
开发者ID:sdh100shaun,项目名称:pantheon,代码行数:61,代码来源:bp-groups-notifications.php

示例7: groups_notification_group_updated

/**
 * Notify all group members when a group is updated.
 *
 * @since 1.0.0
 *
 * @param int                  $group_id  ID of the group.
 * @param BP_Groups_Group|null $old_group Group before new details were saved.
 */
function groups_notification_group_updated($group_id = 0, $old_group = null)
{
    $group = groups_get_group($group_id);
    if ($old_group instanceof BP_Groups_Group) {
        $changed = array();
        if ($group->name !== $old_group->name) {
            $changed[] = sprintf(_x('* Name changed from "%s" to "%s".', 'Group update email text', 'buddypress'), esc_html($old_group->name), esc_html($group->name));
        }
        if ($group->description !== $old_group->description) {
            $changed[] = sprintf(_x('* Description changed from "%s" to "%s".', 'Group update email text', 'buddypress'), esc_html($old_group->description), esc_html($group->description));
        }
    }
    /**
     * Filters the bullet points listing updated items in the email notification after a group is updated.
     *
     * @since 2.2.0
     *
     * @param array $changed Array of bullet points.
     */
    $changed = apply_filters('groups_notification_group_update_updated_items', $changed);
    $changed_text = '';
    if (!empty($changed)) {
        $changed_text = implode("\n", $changed);
    }
    $user_ids = BP_Groups_Member::get_group_member_ids($group->id);
    foreach ((array) $user_ids as $user_id) {
        // Continue if member opted out of receiving this email.
        if ('no' === bp_get_user_meta($user_id, 'notification_groups_group_updated', true)) {
            continue;
        }
        $unsubscribe_args = array('user_id' => $user_id, 'notification_type' => 'groups-details-updated');
        $args = array('tokens' => array('changed_text' => $changed_text, 'group' => $group, 'group.id' => $group_id, 'group.url' => esc_url(bp_get_group_permalink($group)), 'group.name' => $group->name, 'unsubscribe' => esc_url(bp_email_get_unsubscribe_link($unsubscribe_args))));
        bp_send_email('groups-details-updated', (int) $user_id, $args);
    }
    /**
     * Fires after the notification is sent that a group has been updated.
     *
     * See https://buddypress.trac.wordpress.org/ticket/3644 for blank message parameter.
     *
     * @since 1.5.0
     * @since 2.5.0 $subject has been unset and is deprecated.
     *
     * @param array  $user_ids Array of user IDs to notify about the update.
     * @param string $subject  Deprecated in 2.5; now an empty string.
     * @param string $value    Empty string preventing PHP error.
     * @param int    $group_id ID of the group that was updated.
     */
    do_action('bp_groups_sent_updated_email', $user_ids, '', '', $group_id);
}
开发者ID:buddypress,项目名称:BuddyPress-build,代码行数:57,代码来源:bp-groups-notifications.php

示例8: bpfb_documents_allowed

/**
 * Checks upload permissions.
 * Adapted from Group Documents plugin.
 */
function bpfb_documents_allowed($group = false)
{
    if (!$group) {
        return false;
    }
    $user = wp_get_current_user();
    $moderator_of = BP_Groups_Member::get_is_admin_of($user->ID) + BP_Groups_Member::get_is_mod_of($user->ID);
    $moderator_of = is_array($moderator_of) && isset($moderator_of['groups']) ? $moderator_of['groups'] : false;
    $is_mod = false;
    foreach ($moderator_of as $gm) {
        if ($gm->id == $group->id) {
            $is_mod = true;
            break;
        }
    }
    switch (get_option('bp_group_documents_upload_permission')) {
        case 'mods_decide':
            switch (groups_get_groupmeta($group->id, 'group_documents_upload_permission')) {
                case 'mods_only':
                    if ($is_mod) {
                        return true;
                    }
                    break;
                case 'members':
                default:
                    if (bp_group_is_member($group)) {
                        return true;
                    }
                    break;
            }
            break;
        case 'mods_only':
            if ($is_mod) {
                return true;
            }
            break;
        case 'members':
        default:
            if (bp_group_is_member($group)) {
                return true;
            }
            break;
    }
    return false;
}
开发者ID:netconstructor,项目名称:buddypress-activity-plus,代码行数:49,代码来源:bpfb_group_documents.php

示例9: groups_notification_group_updated

function groups_notification_group_updated( $group_id ) {
	global $bp;

	$group    = new BP_Groups_Group( $group_id );
	$sitename = wp_specialchars_decode( get_blog_option( BP_ROOT_BLOG, 'blogname' ), ENT_QUOTES );
	$subject  = '[' . $sitename . '] ' . __( 'Group Details Updated', 'buddypress' );

	$user_ids = BP_Groups_Member::get_group_member_ids( $group->id );
	foreach ( (array)$user_ids as $user_id ) {
		if ( 'no' == get_user_meta( $user_id, 'notification_groups_group_updated', true ) ) continue;

		$ud = bp_core_get_core_userdata( $user_id );

		// Set up and send the message
		$to = $ud->user_email;

		$group_link = site_url( $bp->groups->slug . '/' . $group->slug );
		$settings_link = bp_core_get_user_domain( $user_id ) .  BP_SETTINGS_SLUG . '/notifications/';

		$message = sprintf( __(
'Group details for the group "%s" were updated:

To view the group: %s

---------------------
', 'buddypress' ), $group->name, $group_link );

		$message .= sprintf( __( 'To disable these notifications please log in and go to: %s', 'buddypress' ), $settings_link );

		/* Send the message */
		$to = apply_filters( 'groups_notification_group_updated_to', $to );
		$subject = apply_filters( 'groups_notification_group_updated_subject', $subject, &$group );
		$message = apply_filters( 'groups_notification_group_updated_message', $message, &$group, $group_link );

		wp_mail( $to, $subject, $message );

		unset( $message, $to );
	}
}
开发者ID:n-sane,项目名称:zaroka,代码行数:39,代码来源:bp-groups-notifications.php

示例10: bp_legacy_theme_ajax_invite_user

/**
 * Invites a friend to join a group via a POST request.
 *
 * @since BuddyPress (1.2)
 * @todo Audit return types
 */
function bp_legacy_theme_ajax_invite_user()
{
    // Bail if not a POST action
    if ('POST' !== strtoupper($_SERVER['REQUEST_METHOD'])) {
        return;
    }
    check_ajax_referer('groups_invite_uninvite_user');
    if (!$_POST['friend_id'] || !$_POST['friend_action'] || !$_POST['group_id']) {
        return;
    }
    if (!bp_groups_user_can_send_invites($_POST['group_id'])) {
        return;
    }
    if (!friends_check_friendship(bp_loggedin_user_id(), $_POST['friend_id'])) {
        return;
    }
    $group_id = (int) $_POST['group_id'];
    $friend_id = (int) $_POST['friend_id'];
    if ('invite' == $_POST['friend_action']) {
        $group = groups_get_group($group_id);
        // Users who have previously requested membership do not need
        // another invitation created for them
        if (BP_Groups_Member::check_for_membership_request($friend_id, $group_id)) {
            $user_status = 'is_pending';
            // Create the user invitation
        } elseif (groups_invite_user(array('user_id' => $friend_id, 'group_id' => $group_id))) {
            $user_status = 'is_invited';
            // Miscellaneous failure
        } else {
            return;
        }
        $user = new BP_Core_User($friend_id);
        $uninvite_url = bp_is_current_action('create') ? bp_get_groups_directory_permalink() . 'create/step/group-invites/?user_id=' . $friend_id : bp_get_group_permalink($group) . 'send-invites/remove/' . $friend_id;
        echo '<li id="uid-' . esc_attr($user->id) . '">';
        echo $user->avatar_thumb;
        echo '<h4>' . $user->user_link . '</h4>';
        echo '<span class="activity">' . esc_attr($user->last_active) . '</span>';
        echo '<div class="action">
				<a class="button remove" href="' . wp_nonce_url($uninvite_url, 'groups_invite_uninvite_user') . '" id="uid-' . esc_attr($user->id) . '">' . __('Remove Invite', 'buddypress') . '</a>
			  </div>';
        if ('is_pending' == $user_status) {
            echo '<p class="description">' . sprintf(__('%s has previously requested to join this group. Sending an invitation will automatically add the member to the group.', 'buddypress'), $user->user_link) . '</p>';
        }
        echo '</li>';
        exit;
    } elseif ('uninvite' == $_POST['friend_action']) {
        // Users who have previously requested membership should not
        // have their requests deleted on the "uninvite" action
        if (BP_Groups_Member::check_for_membership_request($friend_id, $group_id)) {
            return;
        }
        // Remove the unsent invitation
        if (!groups_uninvite_user($friend_id, $group_id)) {
            return;
        }
        exit;
    } else {
        return;
    }
}
开发者ID:kosir,项目名称:thatcamp-org,代码行数:66,代码来源:buddypress-functions.php

示例11: bp_em_group_events_build_sql_conditions

function bp_em_group_events_build_sql_conditions($conditions, $args)
{
    if (!empty($args['group']) && is_numeric($args['group'])) {
        $conditions['group'] = "( `group_id`={$args['group']} )";
    } elseif (!empty($args['group']) && $args['group'] == 'my') {
        $groups = groups_get_user_groups(get_current_user_id());
        if (count($groups) > 0) {
            $conditions['group'] = "( `group_id` IN (" . implode(',', $groups['groups']) . ") )";
        }
    }
    //deal with private groups and events
    if (is_user_logged_in()) {
        global $wpdb;
        //find out what private groups they belong to, and don't show private group events not in their memberships
        $group_ids = BP_Groups_Member::get_group_ids(get_current_user_id());
        if ($group_ids['total'] > 0) {
            $conditions['group_privacy'] = "(`event_private`=0 OR (`event_private`=1 AND (`group_id` IS NULL OR `group_id` = 0)) OR (`event_private`=1 AND `group_id` IN (" . implode(',', $group_ids['groups']) . ")))";
        } else {
            //find out what private groups they belong to, and don't show private group events not in their memberships
            $conditions['group_privacy'] = "(`event_private`=0 OR (`event_private`=1 AND (`group_id` IS NULL OR `group_id` = 0)))";
        }
    }
    return $conditions;
}
开发者ID:pyropictures,项目名称:wordpress-plugins,代码行数:24,代码来源:bp-em-groups.php

示例12: test_user_can_dissociate_from_group_within_group_mod

 /**
  * @group map_meta_cap
  * @group dissociate_from_group
  */
 public function test_user_can_dissociate_from_group_within_group_mod()
 {
     $g = $this->factory->group->create();
     $old_current_user = get_current_user_id();
     $u1 = $this->factory->user->create();
     $gm1 = new BP_Groups_Member($u1, $g);
     $gm1->promote('admin');
     $this->set_current_user($u1);
     $this->go_to(bp_get_group_permalink(groups_get_group(array('group_id' => $g))));
     // $this->go_to( bp_docs_get_doc_link( $post_id ) );
     $this->assertTrue(current_user_can('bp_docs_dissociate_from_group'));
 }
开发者ID:Apatrid,项目名称:buddypress-docs,代码行数:16,代码来源:test-permissions.php

示例13: groups_remove_data_for_user

/**
 * Delete all group membership information for the specified user.
 *
 * @since 1.0.0
 *
 * @param int $user_id ID of the user.
 */
function groups_remove_data_for_user($user_id)
{
    BP_Groups_Member::delete_all_for_user($user_id);
    /**
     * Fires after the deletion of all data for a user.
     *
     * @since 1.1.0
     *
     * @param int $user_id ID of the user whose data is being deleted.
     */
    do_action('groups_remove_data_for_user', $user_id);
}
开发者ID:jasonmcalpin,项目名称:BuddyPress,代码行数:19,代码来源:bp-groups-functions.php

示例14: groups_remove_data_for_user

function groups_remove_data_for_user($user_id)
{
    global $bp;
    BP_Groups_Member::delete_all_for_user($user_id);
    bp_core_delete_notifications_from_user($user_id, $bp->groups->id, 'new_membership_request');
    do_action('groups_remove_data_for_user', $user_id);
}
开发者ID:novichkovv,项目名称:candoweightloss,代码行数:7,代码来源:bp-groups-functions.php

示例15: bp_admin_repair_group_count

/**
 * Recalculate group counts for each user.
 *
 * @since BuddyPress (2.0.0)
 *
 * @return array
 */
function bp_admin_repair_group_count()
{
    global $wpdb;
    if (!bp_is_active('groups')) {
        return;
    }
    $statement = __('Counting the number of groups for each user&hellip; %s', 'buddypress');
    $result = __('Failed!', 'buddypress');
    $sql_delete = "DELETE FROM {$wpdb->usermeta} WHERE meta_key IN ( 'total_group_count' );";
    if (is_wp_error($wpdb->query($sql_delete))) {
        return array(1, sprintf($statement, $result));
    }
    $bp = buddypress();
    // Walk through all users on the site
    $total_users = $wpdb->get_row("SELECT count(ID) as c FROM {$wpdb->users}")->c;
    if ($total_users > 0) {
        $per_query = 500;
        $offset = 0;
        while ($offset < $total_users) {
            // But only bother to update counts for users that have groups
            $users = $wpdb->get_col($wpdb->prepare("SELECT user_id FROM {$bp->groups->table_name_members} WHERE is_confirmed = 1 AND is_banned = 0 AND user_id > %d AND user_id <= %d", $offset, $offset + $per_query));
            foreach ($users as $user) {
                BP_Groups_Member::refresh_total_group_count_for_user($user);
            }
            $offset += $per_query;
        }
    } else {
        return array(2, sprintf($statement, $result));
    }
    return array(0, sprintf($statement, __('Complete!', 'buddypress')));
}
开发者ID:un1coin,项目名称:ovn-space,代码行数:38,代码来源:bp-core-admin-tools.php


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