sourcecode

알림 및 확인 프로세스 없이 WordPress에서 기본 관리자 이메일 주소를 변경하는 방법

codebag 2023. 3. 14. 21:37
반응형

알림 및 확인 프로세스 없이 WordPress에서 기본 관리자 이메일 주소를 변경하는 방법

스테이징 서버에 스테이징 사이트의 관리자 이메일 주소를 변경할 사이트를 하나 만들었습니다.그 때 스테이징 사이트에서 테스트를 하고 싶은데 클라이언트(원래 관리자 이메일)로 이메일을 보내지 않도록 하고 싶기 때문에 메인 관리자 이메일을 변경하고 싶습니다.

그러나 관리자 이메일을 변경하면 새 관리자 이메일 주소로 확인 링크가 나타납니다.

관리자 이메일 주소는 확인 이메일의 링크를 클릭할 때까지 변경되지 않습니다.

확인 링크를 클릭하면 원래 관리자에게 Admin Email Change 알림이 나타납니다.

WordPress에서 Admin Email Change 알림과 새 Admin Email Address 확인 링크를 비활성화합니다.

어떻게 하는 거죠?도와주실 수 있나요?이거 암호 같은 거 없어요?

여기에 이미지 설명 입력

옵션 테이블의 모든 설정을 변경할 수 있는 '비밀' 설정 페이지가 있습니다.

/options-general에서 URL을 변경하여 액세스합니다.php에서 /param으로 이동합니다.php

서드파티 플러그인을 사용하지 않고 관리 이메일을 변경하는 방법은 몇 가지 있습니다.

admin_email 외 、 _른른른 른른른 른른 른른 른른른 른른 。admin_emailDB로 한 new_admin_email

데이터베이스를 통한 업데이트:

통해 직접 옵션을 및 DB의 두 입니다.admin_email ★★★★★★★★★★★★★★★★★」new_admin_email

UPDATE wp_options SET option_value = 'admin@example.com' WHERE 
option_name LIKE 'admin_email' 
OR 
option_name LIKE 'new_admin_email';

주의: 모든 WordPress 데이터베이스에는 기본적으로wp_테이블 프리픽스는 변경할 수 있습니다.따라서 wp-config.disc에 체크인을 합니다.$table_prefix 치치 value.

옵션을 통한 업데이트.php:

또 다른 은 앞서 바와 같이 입니다./wp-admin/options.php너무 선택지가 수 있고, 선택지가 있기 때문에또한 여러 가지 이유로 인해$_POST변수 제한은 서버마다 다르게 설정되어 있기 때문에 변경할 수 없습니다.

것은, 「」을 참조해 주세요.max_input_vars https://www.php.net/manual/en/info.configuration.php

기능을 통한 업데이트.php(액티브 테마):

함수에 타임 코드를 1개 설정할 수 있습니다(및 그 후에 삭제할 수도 있습니다).다음 옵션을 갱신하려면 , 액티브 테마의 phpp

update_option( 'admin_email', 'admin@example.com' );

그리고.

update_option( 'new_admin_email', 'admin@example.com' ); 

이것들을 몇 개 안에 넣어 주세요.admin_init액션 콜백

wp-cli를 통한 업데이트:

관리 이메일을 갱신하는 또 다른 방법은 wp-cli를 사용하는 것입니다(터미널 ssh에 액세스할 수 있는 경우).

wp option update admin_email 'admin@example.com'

그리고.

wp option update new_admin_email 'admin@example.com'

wp 옵션명령어에 대한 자세한 내용은 다음과 같습니다.

https://developer.wordpress.org/cli/commands/option/update/

대체하려는 것은 Wordpress 설정의 이메일이지 wp 사용자의 이메일이 아닙니다.테이블 내의 데이터베이스에서 직접 변경할 수 있습니다.wp_options어디에option_nameadmin_email

또는 지정된 업데이트 쿼리를 사용하는 경우:

UPDATE `wp_options` SET `option_value` = 'new@email.com' WHERE `option_name` = 'admin_email';

주의: 먼저 덤프를 가져와 로컬에서 사용해 보십시오.실가동 중에 테스트하지 마세요.

DB로 변경

//email
UPDATE `wp_users` SET `user_email` = "new_email_address" WHERE `wp_users`.`user_login` = "admin";

//password
UPDATE `wp_users` SET `user_pass` = MD5('new_password_here') WHERE `wp_users`.`user_login` = "admin";

이것도 체크해주세요

네트워크 관리 이메일이 wp_sitemeta 테이블에서 변경되었습니다.네트워크 관리자 설정을 변경할 수 없는 경우 이메일을 업데이트하려면 phpmyadmin 또는 mysql 클라이언트에서 다음 쿼리를 사용합니다.

UPDATE `wp_sitemeta` SET `meta_value` = 'the_new_email@abc.com' WHERE `meta_value` = 'the_old_email@abc.com';

주의: 고객님의 경우 wp가 아닌 경우 db에서 사용되는 테이블 접두사를 사용하십시오.

변경할 엔트리를 알고 싶다면 wp_sitemeata 테이블의 이미지를 보십시오.

phpMyAdmin 사용이 용이함

wp_mails > admin_email

mysql 서버를 입력해야 합니다.

다음 쿼리를 실행합니다.

UPDATE `wp_options` SET `option_value` = 'mail@email.com' WHERE `option_id` = 6;

이 쿼리를 실행합니다. 그러면 확인 없이 이메일 ID가 변경됩니다.

UPDATE `wp_users` SET `user_email` = 'newemail' WHERE `user_email` = 'old_email';

저도 같은 문제가 있어서 확인 링크 기능을 롤백하기 위한 플러그인을 작성했습니다..org repo에서 다운로드할 수 있습니다.

아웃바운드 전자 메일 없이 관리자 전자 메일 설정 변경

코드는 다음과 같습니다.

<?php
/*
 Plugin Name: Change Admin Email Setting Without Outbound Email
 Plugin URI: https://wp-bdd.com/change-admin-email/
 Description: Restores functionality removed since WordPress 4.9. Allows the changing of the admin email by admins in single site without outbound email or recipient email credentials.
 Version: 1.0
 Author: John Dee
 Author URI: https://wp-bdd.com/
*/

$ChangeAdminEmailPlugin = new ChangeAdminEmailPlugin;

class ChangeAdminEmailPlugin{

    public function __construct(){

        //This plugin doesn't do anything unless it's WordPres version +4.9 and single site
        if($this->isWordPressMinimiumVersion("4.9.0") && (!( is_multisite()))){
            //pulls the default actions
            remove_action( 'add_option_new_admin_email', 'update_option_new_admin_email' );
            remove_action( 'update_option_new_admin_email', 'update_option_new_admin_email' );

            //When you actually complete the change, another email gets fired to the old address
            //this filter overides this:
            add_filter('send_site_admin_email_change_email', function(){return FALSE;}, 10, 3 );

            //hooks our own custom method to update the email
            add_action( 'add_option_new_admin_email', array($this, 'updateOptionAdminEmail'), 10, 2 );
            add_action( 'update_option_new_admin_email', array($this, 'updateOptionAdminEmail'), 10, 2 );

            //this fixes the text in English. Translators wanted for other languages.
            add_action('wp_after_admin_bar_render', array($this, 'modifyOptionsGeneralPHPForm'));
        }
    }

    public function updateOptionAdminEmail( $old_value, $value ) {
        update_option( 'admin_email', $value );
    }

    public function isWordPressMinimiumVersion($version){
        global $wp_version;
        if (version_compare($wp_version, $version, ">=")) {
            return TRUE;
        } else {
            return FALSE;
        }
    }

    //Changes the form on admin area options-general.php. Doesn't do anything unless on this page.
    public function modifyOptionsGeneralPHPForm(){
        $screen = get_current_screen();
        if($screen->base == "options-general"){
            add_filter( 'gettext', array($this, 'filterText'), 10, 3 );
        }
    }

    //Changes the English text of WP core. Inspired by https://wordpress.stackexchange.com/questions/188332/override-default-wordpress-core-translation
    public function filterText( $translated, $original, $domain ) {
        if ( $translated == "This address is used for admin purposes. If you change this we will send you an email at your new address to confirm it. <strong>The new address will not become active until confirmed.</strong>"){
            $translated = __("This address is used for admin purposes.");
        }
        return $translated;
    }

}

테마 기능에 다음의 코드를 추가하는 것만으로, E-메일 확인을 무효로 할 수 있습니다.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', 10, 2 );
add_action( 'update_option_new_admin_email', 'wpdocs_update_option_new_admin_email', 10, 2 );

옵션 테이블에 'new_admin_email' 행이 없을 수 있다는 다른 답변을 추가합니다.

new_admin_email' 값은 일반 설정 페이지(/wp-admin/options-general.php)를 통해 원래 관리 이메일을 변경하려고 시도한 후에만 설정됩니다.그리고 보류 중인 변경을 취소하면 삭제됩니다.

언급URL : https://stackoverflow.com/questions/48201505/how-to-change-main-admin-email-address-in-wordpress-without-notification-and-con

반응형