bp_activity_action_delete_activity (intactivity_id美元)
删除特定的活动项目并重定向到上一页。
描述
参数
- activity_id美元
-
(int)(必需)要删除的活动id。默认值为0。
返回
(保龄球);如果执行失败将返回False。
源
文件:bp-activity /行动/ delete.php
function bp_activity_action_delete_activity($activity_id = 0){//不查看活动或动作不删除。bp_is_activity_component() || !bp_is_current_action('delete'))返回false;If (empty($activity_id) && bp_action_variable(0))) $activity_id = (int) bp_action_variable(0); / /将bp_action_variable赋值为0//不查看特定的活动项。If (empty($activity_id))返回false;//检查nonce。check_admin_referer(“bp_activity_delete_link”);//加载活动项。$activity = new BP_Activity_Activity($activity_id);/ /检查访问。 if ( ! bp_activity_user_can_delete( $activity ) ) return false; /** * Fires before the deletion so plugins can still fetch information about it. * * @since BuddyPress 1.5.0 * * @param int $activity_id The activity ID. * @param int $user_id The user associated with the activity. */ do_action( 'bp_activity_before_action_delete_activity', $activity_id, $activity->user_id ); // Delete the activity item and provide user feedback. if ( bp_activity_delete( array( 'id' => $activity_id, 'user_id' => $activity->user_id ) ) ) bp_core_add_message( __( 'Activity deleted successfully', 'buddyboss' ) ); else bp_core_add_message( __( 'There was an error when deleting that activity', 'buddyboss' ), 'error' ); /** * Fires after the deletion so plugins can act afterwards based on the activity. * * @since BuddyPress 1.1.0 * * @param int $activity_id The activity ID. * @param int $user_id The user associated with the activity. */ do_action( 'bp_activity_action_delete_activity', $activity_id, $activity->user_id ); // Check for the redirect query arg, otherwise let WP handle things. if ( !empty( $_GET['redirect_to'] ) ) bp_core_redirect( esc_url( $_GET['redirect_to'] ) ); else bp_core_redirect( wp_get_referer() ); }
更新日志
版本 | 描述 |
---|---|
BuddyPress 1.1.0 | 介绍了。 |