bp_activity_action_spam_activity (intactivity_id美元)
将特定的活动项目标记为垃圾邮件并重定向到前一页。
描述
参数
- activity_id美元
-
(int)(必需)要删除的活动id。默认值为0。
返回
(保龄球);如果执行失败将返回False。
源
函数bp_activity_action_spam_activity($activity_id = 0) {$bp = buddypress();//不查看活动,或动作不是垃圾邮件,或Akismet不存在。If (!bp_is_activity_component() || !bp_is_current_action('spam') || empty($bp->activity->akismet))返回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;//当前用户是否允许发送垃圾邮件?If (!bp_activity_user_can_mark_spam())返回false;//加载活动项。$activity = new BP_Activity_Activity($activity_id); if ( empty( $activity->id ) ) return false; // Check nonce. check_admin_referer( 'bp_activity_akismet_spam_' . $activity->id ); /** * Fires before the marking activity as spam so plugins can modify things if they want to. * * @since BuddyPress 1.6.0 * * @param int $activity_id Activity ID to be marked as spam. * @param object $activity Activity object for the ID to be marked as spam. */ do_action( 'bp_activity_before_action_spam_activity', $activity->id, $activity ); // Mark as spam. bp_activity_mark_as_spam( $activity ); $activity->save(); // Tell the user the spamming has been successful. bp_core_add_message( __( 'The activity item has been marked as spam and is no longer visible.', 'buddyboss' ) ); /** * Fires after the marking activity as spam so plugins can act afterwards based on the activity. * * @since BuddyPress 1.6.0 * * @param int $activity_id Activity ID that was marked as spam. * @param int $user_id User ID associated with activity. */ do_action( 'bp_activity_action_spam_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.6.0 | 介绍了。 |