自定义或避免新的管理员电子邮件地址通知

时间:2015-03-04 作者:Luis Martins

在多站点网络中,当您在设置/常规中更改主电子邮件地址时,Wordpress会发送一封必须由新电子邮件收件人确认的电子邮件。

我需要避免或自定义正在发送的消息,但不知道如何发送。

负责发送此电子邮件的功能不可插入,如下所示:

/**
 * Sends an email when a site administrator email address is changed.
 *
 * @since 3.0.0
 *
 * @param string $old_value The old email address. Not currently used.
 * @param string $value     The new email address.
 */
function update_option_new_admin_email( $old_value, $value ) {
    if ( $value == get_option( \'admin_email\' ) || !is_email( $value ) )
        return;

    $hash = md5( $value. time() .mt_rand() );
    $new_admin_email = array(
        \'hash\' => $hash,
        \'newemail\' => $value
    );
    update_option( \'adminhash\', $new_admin_email );

    $email_text = __( \'Dear user,

You recently requested to have the administration email address on
your site changed.
If this is correct, please click on the following link to change it:
###ADMIN_URL###

You can safely ignore and delete this email if you do not want to
take this action.

This email has been sent to ###EMAIL###

Regards,
All at ###SITENAME###
###SITEURL###\' );
此函数将继续,并有一些过滤器来更改某些变量,但无法自定义消息本身。

您知道有什么方法可以避免在多站点中需要此通知,或者至少可以覆盖它发送的消息吗?

2 个回复
最合适的回答,由SO网友:David Gard 整理而成

看来我对你答案的编辑被拒绝了,所以给你。

所缺少的只是$priority$accepted_args 的参数add_action() 调用,下面的固定代码应该可以完成您所需要的。

remove_action( \'add_option_new_admin_email\', \'update_option_new_admin_email\' );
remove_action( \'update_option_new_admin_email\', \'update_option_new_admin_email\' );

/**
 * Disable the confirmation notices when an administrator
 * changes their email address.
 *
 * @see http://codex.wordpress.com/Function_Reference/update_option_new_admin_email
 */
function wpdocs_update_option_new_admin_email( $old_value, $value ) {

    update_option( \'admin_email\', $value );
}
add_action( \'add_option_new_admin_email\', \'wpdocs_update_option_new_admin_email\', 10, 2 );
add_action( \'update_option_new_admin_email\', \'wpdocs_update_option_new_admin_email\', 10, 2 );

SO网友:Luis Martins

正如David Gard所指出的,这很容易做到:

<?php

remove_action( \'add_option_new_admin_email\', \'update_option_new_admin_email\' );
remove_action( \'update_option_new_admin_email\', \'update_option_new_admin_email\' );

/**
 * Disable the confirmation notices when an administrator
 * changes their email address.
 *
 * @see http://codex.wordpress.com/Function_Reference/update_option_new_admin_email
 */
function wpdocs_update_option_new_admin_email( $old_value, $value ) {

    update_option( \'admin_email\', $value );
}
add_action( \'add_option_new_admin_email\', \'wpdocs_update_option_new_admin_email\' );
add_action( \'update_option_new_admin_email\', \'wpdocs_update_option_new_admin_email\' );

?>
编辑:Codex文档被标记为“需要更新”,我已经确认它在当前格式下不起作用。

结束

相关推荐

与wp_USERS一起查询wp_usermeta

我想使用WordPress查询功能,而不需要外部插件。以下是我目前掌握的情况:add_filter(\'user_search_columns\', \'user_search_columns_bd\' , 10, 3); function user_search_columns_bd($search_columns, $search, $this){ if(!in_array(\'display_name\', $search_columns)){