__( 'Site name', 'all-in-one-utilities' ), 'username' => __( 'New user\'s username', 'all-in-one-utilities' ), 'user_email' => __( 'New user\'s email address', 'all-in-one-utilities' ), ); } /** * {@inheritDoc} */ public function register(): void { add_filter( 'wp_send_new_user_notification_to_admin', array( $this, 'maybe_suppress' ) ); add_filter( 'wp_new_user_notification_email_admin', array( $this, 'apply' ), 10, 3 ); } /** * Don't send at all when switched off. * * @param bool $send Whether core will send it. * @return bool */ public function maybe_suppress( $send ) { return $send && $this->is_enabled(); } /** * Rewrite core's email. * * @param array $email Core's email. * @param WP_User $user The new user. * @param string $blogname Site name. * @return array */ public function apply( $email, $user, $blogname ) { if ( ! $user instanceof WP_User ) { return $email; } return $this->rewrite( (array) $email, array( 'site_name' => (string) $blogname, 'username' => $user->user_login, 'user_email' => $user->user_email, ), array( 'user' => $user, 'blogname' => $blogname, ) ); } }