<?xml version="1.0" encoding="UTF-8" ?>
<rss version="2.0">
	<channel>
				<title><![CDATA[모든 게시판의 모든 댓글을 관리자에게 알림 설정을 하려고 하는데 기존 코드들 때문인지 치명적인 오류가 뜹니다. 도와주세요 ㅜㅜ]]></title>
		<link>https://www.cosmosfarm.com/threads/rss/document/54671</link>
		<description><![CDATA[<p>안녕하세요~ 항상 수고 많으십니다.<br />
 </p>

<p>모든 게시판의 모든 댓글을 관리자에게 알림 메일이 전송 되도록 설정하려고 하고 있습니다.<br />
KBoard 커뮤니티 게시판을 검색해서 관리자에게 모든 댓글이 오도록 하는 코드를 찾아서 추가하면, 기존의 코드들 때문인지 '치명적인 오류'가 뜹니다.<br />
<br />
아래에 제가 추가하려는 코드와 현재 차일드 테마의 'functions.php'에 이미 추가되어 있는 전체 코드를 함께 올려드립니다.<br />
한번 검토해 주시고 귀한 자문을 좀 부탁드립니다.<br />
<br />
고맙습니다.<br />
<br />
----------------------<br />
<br />
[추가하려는 코드]</p>

<pre>
<code>// 모든 게시판의 모든 댓글 관리자에게 알림(관리자 댓글 제외)
add_action('kboard_comments_insert', 'my_admin_comment_email_alert', 10, 2);
function my_admin_comment_email_alert($comment_uid, $content_uid){
	$comment = new KBComment();
	$comment-&gt;initWithUID($comment_uid);
	$content = new KBContent();
	$content-&gt;initWithUID($content_uid);
	$board = $content-&gt;getBoard();
	
	if(!$board-&gt;isAdmin()){
		if(!class_exists('KBMail')){
			include_once KBOARD_DIR_PATH . '/class/KBMail.class.php';
		}
		$url = new KBUrl();
		$mail = new KBMail();
		$mail-&gt;to = get_option('admin_email');
		$mail-&gt;title = "댓글이 등록 되었습니다.";
		$mail-&gt;content = $comment-&gt;content;
		$mail-&gt;url = $url-&gt;getDocumentRedirect($content-&gt;uid);
		$mail-&gt;url_name = '페이지로 이동';
		$mail-&gt;send();
	}
}</code></pre>

<p>------------------------</p>

<p>[차일드 테마의 'functions.php'에 이미 추가되어 있는 전체 코드]</p>

<pre>
<code>&lt;?php
/**
 * Astra Child Theme functions and definitions
 *
 * @link https://developer.wordpress.org/themes/basics/theme-functions/
 *
 * @package Astra Child
 * @since 1.0.0
 */

/**
 * Define Constants
 */
define( 'CHILD_THEME_ASTRA_CHILD_VERSION', '1.0.0' );

/**
 * Enqueue styles
 */
function child_enqueue_styles() {

	wp_enqueue_style( 'astra-child-theme-css', get_stylesheet_directory_uri() . '/style.css', array('astra-theme-css'), CHILD_THEME_ASTRA_CHILD_VERSION, 'all' );

}

add_action( 'wp_enqueue_scripts', 'child_enqueue_styles', 15 );


// 큰 이미지 파일 업로드 시 이미지 임계값(image threshold) 제한 해제하기
add_filter( 'big_image_size_threshold', '__return_false' );

// 게시판 작성자 이름 별표
add_filter('kboard_user_display', 'my_kboard_user_display', 10, 5);
function my_kboard_user_display($user_display, $user_id, $user_name, $plugins, $boardBuilder){
	$board = $boardBuilder-&gt;board;
	
	if(in_array($board-&gt;id, array('1', '9', '10', '11')) &amp;&amp; !$board-&gt;isAdmin()){ // 실제 게시판 id로 적용해주세요.
		$strlen = mb_strlen($user_name, 'utf-8');
		
		if($strlen &gt; 3){
			$showlen = 2;
		}
		else{
			$showlen = 1;
		}

		$user_display = mb_substr($user_name, 0, $showlen, 'utf-8') . str_repeat(' * ', $strlen-$showlen);
	}

	return $user_display;
}

// 관리자가 댓글 달면 작성자에게 이메일 알림
add_action('kboard_comments_insert', 'my_admin_comment_email_alert', 10, 2);
function my_admin_comment_email_alert($comment_uid, $content_uid){
	$comment = new KBComment();
	$comment-&gt;initWithUID($comment_uid);
	$content = new KBContent();
	$content-&gt;initWithUID($content_uid);
	$board = $content-&gt;getBoard();
	if($board-&gt;isAdmin()){
		if($content-&gt;option-&gt;email){
			if(!class_exists('KBMail')){
				include_once KBOARD_DIR_PATH . '/class/KBMail.class.php';
			}
			$url = new KBUrl();
			$mail = new KBMail();
			$mail-&gt;to = $content-&gt;option-&gt;email;
			$mail-&gt;title = "고객님의 글에 답변이 등록되었습니다.";
			$mail-&gt;content = $comment-&gt;content;
			$mail-&gt;url = $url-&gt;getDocumentRedirect($content-&gt;uid);
			$mail-&gt;url_name = '해당 글로 이동';
			$mail-&gt;send();
		}
	}
}

// 새글 등록 시 작성자에게 바로 안내메일 보내기
add_action('kboard_document_insert', 'my_kboard_document_insert_210804', 10, 2);
function my_kboard_document_insert_210804($content_uid, $board_id){
	$document = new KBContent();
	$document-&gt;initWithUID($content_uid);
	
	if($document-&gt;option-&gt;email){
		if(!class_exists('KBMail')){
			include_once KBOARD_DIR_PATH . '/class/KBMail.class.php';
		}
		
		$url = new KBUrl();
		$mail = new KBMail();
		$mail-&gt;to = $document-&gt;option-&gt;email; // 이메일 필드 메타키
		$mail-&gt;title = '고객님의 신청이 정상적으로 등록되었습니다.';
		$mail-&gt;content = $document-&gt;content;
		$mail-&gt;url = $url-&gt;getDocumentRedirect($document-&gt;uid);
		$mail-&gt;url_name = '해당 글로 이동';
		$mail-&gt;send();
    }
}

// 댓글 작성자에게 대댓글 알림 메일
add_action('kboard_comments_insert', 'my_kboard_comments_insert', 10, 3);
function my_kboard_comments_insert($insert_id, $content_uid, $board){
if(in_array($board-&gt;id, array('9', '10', '11'))){ // 실제 게시판 id로 적용해주세요.
		$comment = new KBComment();
		$comment-&gt;initWithUID($insert_id);
		
		$document = new KBContent();
		$document-&gt;initWithUID($content_uid);
		
		if($comment-&gt;parent_uid){
			$parent_comment = new KBComment();
			$parent_comment-&gt;initWithUID($comment-&gt;parent_uid);
			
			if($parent_comment-&gt;user_uid){
				$user = new WP_User($parent_comment-&gt;user_uid);
				if($user-&gt;user_email &amp;&amp; $user-&gt;ID != get_current_user_id()){
					kboard_mail();
					
					$url = new KBUrl();
					$mail = new KBMail();
					$mail-&gt;to = $user-&gt;user_email;
					$mail-&gt;title = "[댓글알림] {$document-&gt;title}";
					$mail-&gt;content = $comment-&gt;content;
					$mail-&gt;url = $url-&gt;getDocumentRedirect($document-&gt;uid);
					$mail-&gt;url_name = '해당 글로 이동';
					$mail-&gt;send();
				}
			}
		}
	}
}

// 기술지원게시판 제목(업체명) 마스킹
add_filter('kboard_content_value', 'kboard_content_value_20210728', 10, 3);
function kboard_content_value_20210728($value, $name, $content){
	$board = $content-&gt;getBoard();
	if($name == 'title' &amp;&amp; kboard_mod() != 'editor' &amp;&amp; $board-&gt;id == '11'){ // 실제 게시판 id로 적용해주세요.
		$strlen = mb_strlen($value, 'utf-8');
		
		$value = mb_substr($value, 0, 2, 'utf-8') . str_repeat('*', $strlen-1);
	}
	
	return $value;
}


</code></pre>

<p> </p>]]></description>
		<copyright>Copyright 2026, 코스모스팜</copyright>
				<item>
			<title><![CDATA[네! 앞으론 처음부터 오류코드도 함께 올리겠습니다.

알려주신 대로 추가하려는 코드의 my_admin_comme...]]></title>
			<link>https://www.cosmosfarm.com/threads/document/54695</link>
			<description><![CDATA[<p>네! 앞으론 처음부터 오류코드도 함께 올리겠습니다.<br />
<br />
알려주신 대로 추가하려는 코드의 my_admin_comment_email_alert를 my_admin_comment_email_alert2로 모두 변경했더니 정상적으로 메일이 수신 됩니다.<br />
항상 단번에 완벽한 답변 주셔서 정말 감사합니다.<br />
<br />
장마철 건강에 유념하세요.<br />
<br />
고맙습니다. </p>]]></description>
			<author>단골</author>
			<pubDate>Fri, 13 Aug 2021 06:53:52 +0000</pubDate>
			<category>KBoard</category>
		</item>
				<item>
			<title><![CDATA[안녕하세요~^^

코드 올려주신 것 감사합니다.

그런데 치명적인 에러 코드도 함께 올려주시겠어요?

에...]]></title>
			<link>https://www.cosmosfarm.com/threads/document/54678</link>
			<description><![CDATA[<p>안녕하세요~^^</p>

<p>코드 올려주신 것 감사합니다.</p>

<p>그런데 치명적인 에러 코드도 함께 올려주시겠어요?</p>

<p>에러 코드를 보면 더 정확하게 안내드릴 수 있습니다.</p>

<p> </p>

<p>예상이지만</p>

<p>추가하려는 코드 쪽에서</p>

<p>my_admin_comment_email_alert 이걸</p>

<p>my_admin_comment_email_alert2 이렇게 변경을 해보시겠어요?</p>

<p>고맙습니다.</p>]]></description>
			<author>스레드봇</author>
			<pubDate>Fri, 13 Aug 2021 00:19:28 +0000</pubDate>
			<category>KBoard</category>
		</item>
			</channel>
</rss>