<?xml version="1.0" encoding="UTF-8" ?>
<rss version="2.0">
	<channel>
				<title><![CDATA[kboard_comments_insert 액션 사용으로 댓글 이메일 알림]]></title>
		<link>https://www.cosmosfarm.com/threads/rss/document/12951</link>
		<description><![CDATA[<p>안녕하세요?</p>

<p>케이보드를 잘 사용하고 있습니다.</p>

<p>사용자가 단 댓글에 관리자가 답변을 주면 답변 내용이 사용자에게 이메일 알림 전송되도록 하려고 하는데요.</p>

<p>이 경우 본래 답변을 단 사용자의 이메일을 어떻게 가져올 수 있나요?</p>

<p>감사합니다.</p>
]]></description>
		<copyright>Copyright 2026, 코스모스팜</copyright>
				<item>
			<title><![CDATA[감사합니다.
]]></title>
			<link>https://www.cosmosfarm.com/threads/document/12964</link>
			<description><![CDATA[<p>감사합니다.</p>
]]></description>
			<author>Sky7</author>
			<pubDate>Wed, 22 Mar 2017 07:36:49 +0000</pubDate>
			<category>KBoard</category>
		</item>
				<item>
			<title><![CDATA[댓글을 단 사용자가 회원인지요?

회원이라면 조금 더 간단할 듯합니다.

아래 코드를 테마의 functions...]]></title>
			<link>https://www.cosmosfarm.com/threads/document/12957</link>
			<description><![CDATA[<p>댓글을 단 사용자가 회원인지요?</p>

<p>회원이라면 조금 더 간단할 듯합니다.</p>

<p>아래 코드를 테마의 functions.php 파일에 추가해보시겠어요?</p>

<pre>
<code class="language-php">add_action('kboard_comments_insert', 'my_kboard_comments_insert', 10, 2);
function my_kboard_comments_insert($comment_uid, $content_uid){
	$comment = new KBComment();
	$comment-&gt;initWithUID($insert_id);
	
	if($comment-&gt;parent_uid){
		$parent = new KBComment();
		$parent-&gt;initWithUID($comment-&gt;parent_uid);
		
		if($parent-&gt;user_uid){
			$user = new WP_User($parent-&gt;user_uid);
			
			if($user-&gt;user_email &amp;&amp; $user-&gt;ID != get_current_user_id()){
				
				$title = '등록하신 댓글에 답변이 등록 되었습니다.';
				$content = '등록하신 댓글에 대해 답변이 등록 되었습니다.';
				wp_mail($user-&gt;user_email, $title, $content);
			}
		}
	}
}</code></pre>

<p> </p>

<p>회원이 아니라면 댓글을 남길 때 이메일을 입력받아야겠죠.</p>

<p>아래 코드를 테마의 functions.php 파일에 추가하시면 아마 댓글 입력창에 이메일 입력 필드가 출력될 겁니다.</p>

<pre>
<code class="language-php">add_action('kboard_comments_field', 'my_kboard_comments_field', 5, 4);
function my_kboard_comments_field($field_html, $board, $content_uid, $comment_builder){
	if(!is_user_logged_in()){
		$current_user = wp_get_current_user();
		if(!$current_user-&gt;user_email){
			?&gt;
			&lt;div class="comments-field"&gt;
				&lt;label class="comments-field-label" for="comment_option_email"&gt;이메일&lt;/label&gt;
				&lt;input type="email" id="comment_option_email" name="comment_option_email" value="" placeholder="이메일..." required&gt;
			&lt;/div&gt;
			&lt;?php
		}
	}
}</code></pre>

<p> </p>

<p>그리고 아래 코드를 테마의 functions.php 파일에 추가해보시겠어요?</p>

<p>회원 또는 입력받은 이메일 주소로 이메일이 전송됩니다.</p>

<pre>
<code class="language-php">add_action('kboard_comments_insert', 'my_kboard_comments_insert', 10, 2);
function my_kboard_comments_insert($comment_uid, $content_uid){
	$comment = new KBComment();
	$comment-&gt;initWithUID($comment_uid);
	
	if($comment-&gt;parent_uid){
		$parent = new KBComment();
		$parent-&gt;initWithUID($comment-&gt;parent_uid);
		
		if($parent-&gt;user_uid){
			$user = new WP_User($parent-&gt;user_uid);
			
			if($user-&gt;user_email &amp;&amp; $user-&gt;ID != get_current_user_id()){
				$title = '등록하신 댓글에 답변이 등록 되었습니다.';
				$content = '등록하신 댓글에 대해 답변이 등록 되었습니다.';
				wp_mail($user-&gt;user_email, $title, $content);
			}
		}
		else if($parent-&gt;option-&gt;email){
			$title = '등록하신 댓글에 답변이 등록 되었습니다.';
			$content = '등록하신 댓글에 대해 답변이 등록 되었습니다.';
			wp_mail($parent-&gt;option-&gt;email, $title, $content);
		}
	}
}</code></pre>

<p> </p>

<p>댓글 스킨에서도 새로운 입력 필드를 쉽게 추가하실 수 있습니다.</p>

<pre>
<code class="language-html">&lt;input type="email" name="comment_option_email"&gt;</code></pre>

<p>이렇게 필드를 추가한 다음,</p>

<pre>
<code class="language-php">&lt;?php echo $comment-&gt;option-&gt;email?&gt;</code></pre>

<p>이런 형식의 코드로 입력된 값을 출력하실 수 있습니다.</p>

<p> </p>

<p>댓글이 아닌 게시글 작성자에게 이메일 알림에 대해서 참고 하시라고 링크 남겨드립니다.</p>

<p><a href="http://www.cosmosfarm.com/threads/document/12558" target="_blank">http://www.cosmosfarm.com/threads/document/12558</a></p>

<p><a href="http://www.cosmosfarm.com/threads/document/11766" target="_blank">http://www.cosmosfarm.com/threads/document/11766</a></p>]]></description>
			<author>스레드봇</author>
			<pubDate>Wed, 22 Mar 2017 06:27:43 +0000</pubDate>
			<category>KBoard</category>
		</item>
			</channel>
</rss>