그누커머스 게시글 작성일을 바꾸고 싶습니다. 채택완료
그누보드 팁에 나왔는데로(http://sir.kr/g5_tip/2148" target="_self">http://sir.kr/g5_tip/2148)
했는데
수정화면에서 날짜변경, 조회수 변경칸은 나오는데
수정된값이 저장은 안되네요
그누커머스에서 사용할려면 어떻게 수정해야 할까요?
답변 1개
그누보드 팁 에서
if (!defined("_GNUBOARD_")) exit; // 개별 페이지 접근 불가
// 자신만의 코드를 넣어주세요.
$sql1 = " update $write_table set wr_datetime='$wr_datetime', wr_last='$wr_datetime', wr_hit='$wr_hit' where wr_id = '$wr_id' ";
sql_query($sql1);
?>
위의 부분을 그누커머스에 적용하려면 아래와 같습니다.
</span></font></p><p><font color="#484848" face="돋움, Dotum, sans-serif"><span style="font-size: 14.004px; line-height: 25.2072px;">add_action('write_update_metadata', 'custom_gcboard_update_fn', 10, 2);</span></font></p><p><font color="#484848" face="돋움, Dotum, sans-serif"><span style="font-size: 14.004px; line-height: 25.2072px;">
</span></font></p><p><font color="#484848" face="돋움, Dotum, sans-serif"><span style="font-size: 14.004px; line-height: 25.2072px;">function custom_gcboard_update_fn($wr_id, $w){</span></font></p><p><font color="#484848" face="돋움, Dotum, sans-serif"><span style="font-size: 14.004px; line-height: 25.2072px;"> global $wpdb, $gcboard;</span></font></p><p><font color="#484848" face="돋움, Dotum, sans-serif"><span style="font-size: 14.004px; line-height: 25.2072px;">
</span></font></p><p><font color="#484848" face="돋움, Dotum, sans-serif"><span style="font-size: 14.004px; line-height: 25.2072px;"> $gc = $gcboard->gc;</span></font></p><p><font color="#484848" face="돋움, Dotum, sans-serif"><span style="font-size: 14.004px; line-height: 25.2072px;"> $wr_datetime = isset($_POST['wr_datetime']) ? sanitize_text_field($_POST['wr_datetime']) : '';</span></font></p><p><font color="#484848" face="돋움, Dotum, sans-serif"><span style="font-size: 14.004px; line-height: 25.2072px;"> $wr_hit = isset($_POST['wr_hit']) ? sanitize_text_field($_POST['wr_hit']) : '';</span></font></p><p><font color="#484848" face="돋움, Dotum, sans-serif"><span style="font-size: 14.004px; line-height: 25.2072px;">
</span></font></p><p><font color="#484848" face="돋움, Dotum, sans-serif"><span style="font-size: 14.004px; line-height: 25.2072px;"> if( $wr_datetime || $wr_hit ){</span></font></p><p><font color="#484848" face="돋움, Dotum, sans-serif"><span style="font-size: 14.004px; line-height: 25.2072px;">
</span></font></p><p><font color="#484848" face="돋움, Dotum, sans-serif"><span style="font-size: 14.004px; line-height: 25.2072px;"> $arr_update = $arr_formats = array();</span></font></p><p><font color="#484848" face="돋움, Dotum, sans-serif"><span style="font-size: 14.004px; line-height: 25.2072px;"> $where = array( 'wr_id' => $wr_id );</span></font></p><p><font color="#484848" face="돋움, Dotum, sans-serif"><span style="font-size: 14.004px; line-height: 25.2072px;"> $where_format = array( '%d' );</span></font></p><p><font color="#484848" face="돋움, Dotum, sans-serif"><span style="font-size: 14.004px; line-height: 25.2072px;">
</span></font></p><p><font color="#484848" face="돋움, Dotum, sans-serif"><span style="font-size: 14.004px; line-height: 25.2072px;"> if( $wr_datetime ){</span></font></p><p><font color="#484848" face="돋움, Dotum, sans-serif"><span style="font-size: 14.004px; line-height: 25.2072px;"> $arr_update['wr_datetime'] = $wr_datetime;</span></font></p><p><font color="#484848" face="돋움, Dotum, sans-serif"><span style="font-size: 14.004px; line-height: 25.2072px;"> $arr_formats[] = '%s';</span></font></p><p><font color="#484848" face="돋움, Dotum, sans-serif"><span style="font-size: 14.004px; line-height: 25.2072px;"> }</span></font></p><p><font color="#484848" face="돋움, Dotum, sans-serif"><span style="font-size: 14.004px; line-height: 25.2072px;">
</span></font></p><p><font color="#484848" face="돋움, Dotum, sans-serif"><span style="font-size: 14.004px; line-height: 25.2072px;"> if( $wr_hit ){</span></font></p><p><font color="#484848" face="돋움, Dotum, sans-serif"><span style="font-size: 14.004px; line-height: 25.2072px;"> $arr_update['wr_hit'] = $wr_hit;</span></font></p><p><font color="#484848" face="돋움, Dotum, sans-serif"><span style="font-size: 14.004px; line-height: 25.2072px;"> $arr_formats[] = '%d';</span></font></p><p><font color="#484848" face="돋움, Dotum, sans-serif"><span style="font-size: 14.004px; line-height: 25.2072px;"> }</span></font></p><p><font color="#484848" face="돋움, Dotum, sans-serif"><span style="font-size: 14.004px; line-height: 25.2072px;">
</span></font></p><p><font color="#484848" face="돋움, Dotum, sans-serif"><span style="font-size: 14.004px; line-height: 25.2072px;"> $result = $wpdb->update($gc['write_table'], $arr_update, $where, $arr_formats, $where_format);</span></font></p><p><font color="#484848" face="돋움, Dotum, sans-serif"><span style="font-size: 14.004px; line-height: 25.2072px;">
</span></font></p><p><font color="#484848" face="돋움, Dotum, sans-serif"><span style="font-size: 14.004px; line-height: 25.2072px;"> }</span></font></p><p> </p><p><font color="#484848" face="돋움, Dotum, sans-serif"><span style="font-size: 14.004px; line-height: 25.2072px;">}</span></font></p><p><font color="#484848" face="돋움, Dotum, sans-serif"><span style="font-size: 14.004px; line-height: 25.2072px;">
답변에 대한 댓글 1개
댓글을 작성하려면 로그인이 필요합니다.
답변을 작성하려면 로그인이 필요합니다.
로그인