bp_nouveau_ajax_send_group_invites ()

AJAX发送组邀请。

描述

文件:bp-templates / bp-nouveau包括/团体/ ajax.php

函数bp_nouveau_ajax_send_group_invitation () {$bp = buddypress();$response = array('feedback' => __('邀请无法发送。请再试一次。', 'buddyboss'), 'type' => 'error',);//验证nonce if (empty($_POST['_wpnonce']) || !wp_verify_nonce($_POST['_wpnonce'], ' groups_send_invitation ')) {wp_send_json_error($response); / /发送消息} $group_id = bp_get_current_group_id()?: $ _POST [' group_id '];If (bp_is_group_create() && !空($ _POST [' group_id '] ) ) { $ group_id = (int) $ _POST [' group_id '];} if (! bp_groups_user_can_send_invites( $group_id ) ) { $response['feedback'] = __( 'You are not allowed to send invitations for this group.', 'buddyboss' ); wp_send_json_error( $response ); } if ( empty( $_POST['users'] ) ) { wp_send_json_error( $response ); } if ( ! empty( $_POST['message'] ) ) { $bp->groups->invites_message = wp_kses( wp_unslash( $_POST['message'] ), array() ); add_filter( 'groups_notification_group_invites_message', 'bp_nouveau_groups_invites_custom_message', 10, 1 ); } // For feedback $invited = array(); foreach ( (array) $_POST['users'] as $user_id ) { $invited[ (int) $user_id ] = groups_invite_user( array( 'user_id' => $user_id, 'group_id' => $group_id, ) ); } // Send the invites. groups_send_invites( bp_loggedin_user_id(), $group_id ); if ( ! empty( $_POST['message'] ) ) { unset( $bp->groups->invites_message ); remove_filter( 'groups_notification_group_invites_message', 'bp_nouveau_groups_invites_custom_message', 10, 1 ); } if ( array_search( false, $invited ) ) { $errors = array_keys( $invited, false ); $error_count = count( $errors ); $error_message = sprintf( /* translators: count of users affected */ _n( 'Invitation failed for %s user.', 'Invitation failed for %s users.', $error_count, 'buddyboss' ), number_format_i18n( $error_count ) ); wp_send_json_error( array( 'feedback' => $error_message, 'users' => $errors, 'type' => 'error', ) ); } wp_send_json_success( array( 'feedback' => __( 'Invitations sent.', 'buddyboss' ), 'type' => 'success', ) ); }

更新日志

更新日志
版本 描述
BuddyPress 3.0.0 介绍了。

问题吗?

我们总是很乐意帮助您解决代码或其他问题!搜索我们的开发人员文档联络支持,或与我们联系销售团队