本文整理汇总了PHP中BP_Groups_Member::accept_request方法的典型用法代码示例。如果您正苦于以下问题:PHP BP_Groups_Member::accept_request方法的具体用法?PHP BP_Groups_Member::accept_request怎么用?PHP BP_Groups_Member::accept_request使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BP_Groups_Member
的用法示例。
在下文中一共展示了BP_Groups_Member::accept_request方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: groups_accept_membership_request
/**
* Accept a pending group membership request.
*
* @param int $membership_id ID of the membership object.
* @param int $user_id Optional. ID of the user who requested membership.
* Provide this value along with $group_id to override
* $membership_id.
* @param int $group_id Optional. ID of the group to which membership is being
* requested. Provide this value along with $user_id to
* override $membership_id.
*
* @return bool True on success, false on failure.
*/
function groups_accept_membership_request($membership_id, $user_id = 0, $group_id = 0)
{
if (!empty($user_id) && !empty($group_id)) {
$membership = new BP_Groups_Member($user_id, $group_id);
} else {
$membership = new BP_Groups_Member(false, false, $membership_id);
}
$membership->accept_request();
if (!$membership->save()) {
return false;
}
// Check if the user has an outstanding invite, if so delete it.
if (groups_check_user_has_invite($membership->user_id, $membership->group_id)) {
groups_delete_invite($membership->user_id, $membership->group_id);
}
/**
* Fires after a group membership request has been accepted.
*
* @since 1.0.0
*
* @param int $user_id ID of the user who accepted membership.
* @param int $group_id ID of the group that was accepted membership to.
* @param bool $value If membership was accepted.
*/
do_action('groups_membership_accepted', $membership->user_id, $membership->group_id, true);
return true;
}
示例2: groups_accept_membership_request
function groups_accept_membership_request($membership_id, $user_id = 0, $group_id = 0)
{
if (!empty($user_id) && !empty($group_id)) {
$membership = new BP_Groups_Member($user_id, $group_id);
} else {
$membership = new BP_Groups_Member(false, false, $membership_id);
}
$membership->accept_request();
if (!$membership->save()) {
return false;
}
// Check if the user has an outstanding invite, if so delete it.
if (groups_check_user_has_invite($membership->user_id, $membership->group_id)) {
groups_delete_invite($membership->user_id, $membership->group_id);
}
// Record this in activity streams
$group = groups_get_group(array('group_id' => $membership->group_id));
groups_record_activity(array('action' => apply_filters_ref_array('groups_activity_membership_accepted_action', array(sprintf(__('%1$s joined the group %2$s', 'buddypress'), bp_core_get_userlink($membership->user_id), '<a href="' . bp_get_group_permalink($group) . '">' . esc_attr($group->name) . '</a>'), $membership->user_id, &$group)), 'type' => 'joined_group', 'item_id' => $membership->group_id, 'user_id' => $membership->user_id));
// Send a notification to the user.
groups_notification_membership_request_completed($membership->user_id, $membership->group_id, true);
do_action('groups_membership_accepted', $membership->user_id, $membership->group_id);
return true;
}
示例3: groups_accept_membership_request
function groups_accept_membership_request( $membership_id, $user_id = false, $group_id = false ) {
global $bp;
if ( $user_id && $group_id )
$membership = new BP_Groups_Member( $user_id, $group_id );
else
$membership = new BP_Groups_Member( false, false, $membership_id );
$membership->accept_request();
if ( !$membership->save() )
return false;
/* Check if the user has an outstanding invite, if so delete it. */
if ( groups_check_user_has_invite( $membership->user_id, $membership->group_id ) )
groups_delete_invite( $membership->user_id, $membership->group_id );
/* Modify group member count */
groups_update_groupmeta( $membership->group_id, 'total_member_count', (int) groups_get_groupmeta( $membership->group_id, 'total_member_count') + 1 );
/* Record this in activity streams */
$group = new BP_Groups_Group( $membership->group_id );
groups_record_activity( array(
'action' => apply_filters( 'groups_activity_membership_accepted_action', sprintf( __( '%s joined the group %s', 'buddypress'), bp_core_get_userlink( $membership->user_id ), '<a href="' . bp_get_group_permalink( $group ) . '">' . esc_attr( $group->name ) . '</a>' ), $membership->user_id, &$group ),
'type' => 'joined_group',
'item_id' => $membership->group_id,
'user_id' => $membership->user_id
) );
/* Send a notification to the user. */
require_once ( BP_PLUGIN_DIR . '/bp-groups/bp-groups-notifications.php' );
groups_notification_membership_request_completed( $membership->user_id, $membership->group_id, true );
do_action( 'groups_membership_accepted', $membership->user_id, $membership->group_id );
return true;
}
示例4: groups_accept_membership_request
/**
* Accept a pending group membership request.
*
* @param int $membership_id ID of the membership object.
* @param int $user_id Optional. ID of the user who requested membership.
* Provide this value along with $group_id to override $membership_id.
* @param int $group_id Optional. ID of the group to which membership is being
* requested. Provide this value along with $user_id to override
* $membership_id.
* @return bool True on success, false on failure.
*/
function groups_accept_membership_request($membership_id, $user_id = 0, $group_id = 0)
{
if (!empty($user_id) && !empty($group_id)) {
$membership = new BP_Groups_Member($user_id, $group_id);
} else {
$membership = new BP_Groups_Member(false, false, $membership_id);
}
$membership->accept_request();
if (!$membership->save()) {
return false;
}
// Check if the user has an outstanding invite, if so delete it.
if (groups_check_user_has_invite($membership->user_id, $membership->group_id)) {
groups_delete_invite($membership->user_id, $membership->group_id);
}
do_action('groups_membership_accepted', $membership->user_id, $membership->group_id, true);
return true;
}
示例5: groups_accept_membership_request
function groups_accept_membership_request($membership_id)
{
global $bp;
/* Check the nonce first. */
if (!check_admin_referer('groups_accept_membership_request')) {
return false;
}
$membership = new BP_Groups_Member(false, false, $membership_id);
$membership->accept_request();
if (!$membership->save()) {
return false;
}
/* Modify group member count */
groups_update_groupmeta($membership->group_id, 'total_member_count', (int) groups_get_groupmeta($membership->group_id, 'total_member_count') + 1);
/* Record this in activity streams */
groups_record_activity(array('item_id' => $membership->group_id, 'component_name' => $bp->groups->slug, 'component_action' => 'joined_group', 'is_private' => 0));
/* Send a notification to the user. */
require_once BP_PLUGIN_DIR . '/bp-groups/bp-groups-notifications.php';
groups_notification_membership_request_completed($membership->user_id, $membership->group_id, true);
do_action('groups_membership_accepted', $membership->user_id, $membership->group_id);
return true;
}