그누커머스 자동댓글, 게시판별로 가능할까요?
본문
안녕하세요
그누커머스에서 자동댓글을 사용하기 위해
테마-funtions.php에 아래 코드를 넣어서 사용중입니다.
현재 게시판을 하나 더 만들어서 사용중인데
기존과 다른 스킨입니다.
혹시 자동댓글 내용을 게시판마다 다르게 나오게 할 수 있을까요?
add_action('write_update_metadata', 'gc_auto_comment_write', 10, 2);
function gc_auto_comment_write($wr_id, $w){
global $wpdb, $gcboard;
$gc = $gcboard->gc;
$notice = isset($_POST['notice']) ? $_POST['notice'] : '';
if($w == '' && !$notice){ //글쓰기이고 notice 아니면
$write = gc_get_write( $gc['write_table'], $wr_id );
$cm_num = gc_get_next_num( $gc['comment_table'], $wr_id, 'comment' );
$cm_data = array(
'wr_id' => $wr_id,
'bo_table' => $write['bo_table'],
'cm_parent' => 0,
'cm_num' => $cm_num,
'user_id' => 1,
'user_pass' => '',
'user_display_name' => '자동댓글',
'user_email' => '',
'cm_subject' => '',
'cm_content' => '자동댓글 내용입니다.',
'cm_datetime' => GC_TIME_YMDHIS,
'cm_ip' => $_SERVER['REMOTE_ADDR'],
'cm_option' => ''
);
$formats = array(
'%d',
'%s',
'%d',
'%s',
'%s',
'%s',
'%s',
'%s',
'%s',
'%s',
'%s',
'%s',
'%s'
);
$result = $wpdb->insert( $gc['comment_table'], $cm_data, $formats );
}
}
답변 1
답은 소스상에 있습니다
$gc['write_table'],
게시판의 유일한 조건으로
조건문 즉 if , switch 사용하여
아래 들어가는 문구를 조정 하면됩니다
if($gc['write_table']==공지사항){
$nte='공지사항댓글입니다';
}else{
$nte='다른게시판 댓글입니다';
}
'cm_content' => $nte,
이런식으로 하면됩니다
답변을 작성하시기 전에 로그인 해주세요.