bp_email_unsubscribe_handler ()

处理取消订阅的用户通知电子邮件。

描述

文件:bp-core / bp-core-functions.php

函数bp_email_unsubscribe_handler() {$email = bp_email_get_unsubscribe_type_schema();$ raw_email_type = !($_GET['nt']) ?$ _GET [' nt ']:”;$ raw_hash = !empty($_GET['nh']) ?$ _GET [' nh ']:”;$ raw_user_id = !null ($_GET['uid']) ?absint($_GET['uid']): 0; $new_hash = hash_hmac( 'sha1', "{$raw_email_type}:{$raw_user_id}", bp_email_get_salt() ); // Check required values. if ( ! $raw_user_id || ! $raw_email_type || ! $raw_hash || ! array_key_exists( $raw_email_type, $emails ) ) { $redirect_to = wp_login_url(); $result_msg = __( 'Something has gone wrong.', 'buddyboss' ); $unsub_msg = __( 'Please log in and go to your settings to unsubscribe from notification emails.', 'buddyboss' ); // Check valid hash. } elseif ( ! hash_equals( $new_hash, $raw_hash ) ) { $redirect_to = wp_login_url(); $result_msg = __( 'Something has gone wrong.', 'buddyboss' ); $unsub_msg = __( 'Please log in and go to your settings to unsubscribe from notification emails.', 'buddyboss' ); // Don't let authenticated users unsubscribe other users' email notifications. } elseif ( is_user_logged_in() && get_current_user_id() !== $raw_user_id ) { $result_msg = __( 'Something has gone wrong.', 'buddyboss' ); $unsub_msg = __( 'Please go to your notifications settings to unsubscribe from emails.', 'buddyboss' ); if ( bp_is_active( 'settings' ) ) { $redirect_to = sprintf( '%s%s/notifications/', bp_core_get_user_domain( get_current_user_id() ), bp_get_settings_slug() ); } else { $redirect_to = bp_core_get_user_domain( get_current_user_id() ); } } else { if ( bp_is_active( 'settings' ) ) { $redirect_to = sprintf( '%s%s/notifications/', bp_core_get_user_domain( $raw_user_id ), bp_get_settings_slug() ); } else { $redirect_to = bp_core_get_user_domain( $raw_user_id ); } // Unsubscribe. $meta_key = $emails[ $raw_email_type ]['unsubscribe']['meta_key']; bp_update_user_meta( $raw_user_id, $meta_key, 'no' ); $result_msg = $emails[ $raw_email_type ]['unsubscribe']['message']; $unsub_msg = __( 'You can change this or any other email notification preferences in your email settings.', 'buddyboss' ); } $message = sprintf( '%1$s %3$s', $result_msg, esc_url( $redirect_to ), esc_html( $unsub_msg ) ); bp_core_add_message( $message ); bp_core_redirect( bp_core_get_user_domain( $raw_user_id ) ); exit; }

更新日志

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

问题吗?

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