<?xml version="1.0" encoding="UTF-8" ?>
<rss version="2.0">
	<channel>
				<title><![CDATA[게시글 휴지통 삭제 시 액션 훅]]></title>
		<link>https://www.cosmosfarm.com/threads/rss/document/66561</link>
		<description><![CDATA[<p>1. 정확한 제품 또는 플러그인 이름</p>

<p>케이보드</p>

<p> </p>

<p>2. 상세 내용</p>

<p>안녕하세요? 케이보드 임시저장 플러그인을 커스터마이징하여 관리자뿐 아니라 <strong>모든 회원이 임시저장 기능을 이용</strong>할 수 있도록 만들었습니다.</p>

<p><strong>게시글 공개/비공개(임시저장 포함) 설정에 따라 포인트를 제공</strong>하고 있는데요.</p>

<p>게시글 삭제(휴지통) 시 포인트를 차감해야 하는데, <strong>바로 삭제 기능</strong>을 사용하지 않으면 <strong>kboard_document_delete</strong> 액션훅이 작동하지 않더라고요.</p>

<p><strong>바로삭제 기능은 사용할 수가 없는 상황</strong>이라서, <strong>kboard_document_update</strong> 액션훅을 제가 만든 함수와 함께 사용하고 있습니다.<br />
이를 위해서 <strong>KBContent.class.php</strong>에서 휴지통 이동 및 복구 시 실행되는 함수에다가 <strong>do_action('kboard_document_update', $this-&gt;uid, $this-&gt;board_id, $this, $board);</strong> 한 줄씩 추가했는데요.<br />
테스트해보니 별 문제 없이 잘 작동합니다.</p>

<p>그런데 혹시나 이 부분을 일부러 안 넣으신 <strong>이유</strong>가 있을까 염려되어 이렇게 문의드리게 되었습니다.<br />
만약 <strong>별 문제가 없는 부분이라면 다음 케이보드 업데이트 시 반영</strong>이 가능할까요?</p>

<p>&lt;제가 작성한 함수&gt;</p>

<pre>
<code class="language-php">add_action('kboard_document_update', 'my_kboard_document_insert', 10, 4);
function my_kboard_document_insert($content_uid, $board_id, $content, $board)
{
    if (!in_array($board_id, [10, 15])) {
        $user_id = get_current_user_id();
        $insert_point = 1000;
        if (!in_array($content-&gt;status, ['hide', 'trash']) &amp;&amp; $content-&gt;secret != true) {
            $length = mb_strlen($content-&gt;content, 'utf-8');
            $limit_point = 3000;
            $total = mycred_get_total_by_time('today', 'now', 'my_kboard_document_insert', $user_id);

            if ( mycred_count_ref_id_instances( 'my_kboard_document_insert', $content_uid, $user_id ) % 2 == 0 ) {
                if ($board_id == '14') {
                    if ($length &gt;= 100 &amp;&amp; $total &lt; $limit_point) {
                        mycred_add('my_kboard_document_insert', $user_id, $insert_point, '게시글 작성(혹은 공개로 변경) 포인트', $content_uid);
                    }
                } else {
                    if ($total &lt; $limit_point) {
                        mycred_add('my_kboard_document_insert', $user_id, $insert_point, '게시글 작성(혹은 공개로 변경) 포인트', $content_uid);
                    }
                }
            }
        } else {
            if ( mycred_count_ref_id_instances( 'my_kboard_document_insert', $content_uid, $user_id ) % 2 == 1 ) {
                mycred_subtract('my_kboard_document_insert', $user_id, $insert_point, '게시글 삭제(혹은 임시/비공개로 변경) 포인트 차감', $content_uid);
            }
        }
    }
}</code></pre>

<p> </p>

<p>&lt;수정한 클래스 함수&gt;</p>

<pre>
<code class="language-php">/**
	 * 휴지통으로 이동할 때 실행한다.
	 * @param string $content_uid
	 */
	public function moveReplyToTrash($parent_uid){
		global $wpdb;
		
		$board = $this-&gt;getBoard();
		$board-&gt;meta-&gt;list_total = $board-&gt;getListTotal() - 1;
		
		$results = $wpdb-&gt;get_results("SELECT * FROM `{$wpdb-&gt;prefix}kboard_board_content` WHERE `parent_uid`='$parent_uid'");
		$wpdb-&gt;flush();
		foreach($results as $row){
			if($row-&gt;status != 'trash'){
				$this-&gt;moveReplyToTrash($row-&gt;uid);
			}
		}
		do_action('kboard_document_update', $this-&gt;uid, $this-&gt;board_id, $this, $board);
	}
	
	/**
	 * 휴지통에서 복구할 때 실행한다.
	 * @param string $content_uid
	 */
	public function restoreReplyFromTrash($parent_uid){
		global $wpdb;
		
		$board = $this-&gt;getBoard();
		$board-&gt;meta-&gt;list_total = $board-&gt;getListTotal() + 1;
		
		$results = $wpdb-&gt;get_results("SELECT * FROM `{$wpdb-&gt;prefix}kboard_board_content` WHERE `parent_uid`='$parent_uid'");
		$wpdb-&gt;flush();
		foreach($results as $row){
			if($row-&gt;status != 'trash'){
				$this-&gt;restoreReplyFromTrash($row-&gt;uid);
			}
		}
		do_action('kboard_document_update', $this-&gt;uid, $this-&gt;board_id, $this, $board);
	}</code></pre>

<p> </p>]]></description>
		<copyright>Copyright 2026, 코스모스팜</copyright>
				<item>
			<title><![CDATA[안녕하세요~^^

한번 저희쪽에서 남겨주신 코드를 테스트 해보고

다음 업데이트에 반영할지 논의를 해...]]></title>
			<link>https://www.cosmosfarm.com/threads/document/66565</link>
			<description><![CDATA[<p>안녕하세요~^^</p>

<p>한번 저희쪽에서 남겨주신 코드를 테스트 해보고</p>

<p>다음 업데이트에 반영할지 논의를 해보겠습니다</p>

<p>좋은 의견 감사합니다.</p>

<p>고맙습니다.</p>]]></description>
			<author>스레드봇</author>
			<pubDate>Mon, 25 Sep 2023 01:13:09 +0000</pubDate>
			<category>KBoard</category>
		</item>
			</channel>
</rss>