관리자 승인 대기 중인 글을 승인전까지 리스트 목록에도 보이지 않게 할 수 있나요?

승인대기중인글도 내용 말고 에디터 목록 글들은 다 볼 수 있는데

혹시 유저가 글을 쓰고 승인 대기 중인 글은 승인하기 전까지 목록에 보이지 않게 할 수 있나요?

좋은 정보와 인맥을 동시에, 워드프레스 사용자 단톡방 참여하기
워드프레스 에러 기술지원 서비스 전문가에게 맡기세요
  • 안녕하세요~^^

    필터는 여러 개 중복해서 사용하셔도 문제없습니다.

    다만, PHP에서 같은 함수명을 중복해서 사용할 수는 없습니다.

    올려주신 코드 중에서 아래의 코드를

    /*승인대기 목록에서 안보이게*/
    add_filter('kboard_list_where', 'my_kboard_list_where', 10, 3);
    function my_kboard_list_where($where, $board_id, $content_list){
    	if(in_array($board_id, array('2', '3', '4', '10'))){
    		$where .= "AND (`status`='' OR `status` IS NULL)";
    	}
    	return $where;
    }

    아래의 코드로 교체해보시겠어요?

    /*승인대기 목록에서 안보이게*/
    add_filter('kboard_list_where', 'my_kboard_list_where1', 10, 3);
    function my_kboard_list_where1($where, $board_id, $content_list){
    	if(in_array($board_id, array('2', '3', '4', '10'))){
    		$where .= "AND (`status`='' OR `status` IS NULL)";
    	}
    	return $where;
    }

    고맙습니다.

  • 위의 답변을 보고 펑션파일을 수정하니까 error 코드 500이 뜹니다.

    아래는 펑션파일의 전체 내용입니다. 혹시 펑션파일 안에서 같은 필터가 두개 있어서 충돌이 난 것일까요?

    add_filter('kboard_list_where', 'my_kboard_list_where', 10, 3);

    <?php
    // Exit if accessed directly
    if ( !defined( 'ABSPATH' ) ) exit;
    
    // BEGIN ENQUEUE PARENT ACTION
    // AUTO GENERATED - Do not modify or remove comment markers above or below:
    
    // END ENQUEUE PARENT ACTION
    add_filter('kboard_content_date', 'my_kboard_content_date', 10, 3);
    function my_kboard_content_date($date, $content, $board){
    	$date = date('Y.m.d', strtotime($content->date));
    	return $date;
    }
    function my_login_logo() { ?>
    <style type="text/css">
    body.login div#login h1 a {
    background-image: url(<?php echo get_stylesheet_directory_uri(); ?>/images/site-login-logo.png);
    padding-bottom: 1px;
    }
    </style>
    <?php }
    add_action( 'login_enqueue_scripts', 'my_login_logo' );
    
    /*메인화면에게시글미리보기길이조정*/
    add_shortcode('my_kboard_latest_content_view', 'my_kboard_latest_content_view');
    function my_kboard_latest_content_view($args=array()){
    	global $wpdb;
    	$board_id = '7'; // 보여주고자 하는 게시판 번호 입력 
    	$result = $wpdb->get_row("SELECT * FROM `{$wpdb->prefix}kboard_board_content` WHERE `board_id`='$board_id' AND (`status`='' OR `status` IS NULL OR `status`='pending_approval') ORDER BY `date` DESC LIMIT 1");
    	
    	if($result){
    		$content = new KBContent();
    		$content->initWithUID($result->uid);
    		$url = new KBUrl();
    		$router = new KBRouter();
    		$board_url = $router->getContentURL($result->uid);
    		
    		$content->content = wp_strip_all_tags($content->content);
    		$content->content = mb_strimwidth($content->content, 0, 250, '...', 'utf-8'); // 100 수치를 조절하시면 길이를 조절할 수 있습니다.
    		
    		ob_start();
            echo '<div class="kboard-title">';
            if($content->isNew()){
                echo '<span class="kboard-default-new-notify">N</span>';
            }
            echo '<a href="'.$url->set('uid', $content->uid)->set('mod', 'document')->toStringWithPath($board_url).'"> '.$content->title.'</a></div>';
            echo '<div class="kboard-content">'.$content->content.'</div>';
            return ob_get_clean();
    	}
    }
    
    /*댓글자동링크적용*/
    add_filter('kboard_comments_content', 'my_kboard_comments_content', 10, 3);
    function my_kboard_comments_content($comment, $comment_uid, $content_uid){
    	return preg_replace_callback('#(?i)(http|https)?(://)?(([-\w^@]+\.)+(kr|co.kr|go.kr|net|org|edu|gov|me|com|co+)(?:/[^,\s]*|))#', 'kboard_comment_autolink_prependHTTP', $comment);
    }
    
    function kboard_comment_autolink_prependHTTP($m){
    	$mStr = $m[1].$m[2].$m[3];
    	if(preg_match('#([a-z0-9&\-_.]+?)@([\w\-]+\.([\w\-\.]+\.)*[\w]+)#', $mStr)){
    		return "<a href=\"mailto:".$m[2].$m[3]."\" target=\"_blank\">".$m[1].$m[2].$m[3]."</a>";
    	}
    	else{
    		$http = (!preg_match("#(https://)#", $mStr)) ? 'http://' : 'https://';
    		return "<a href=\"".$http.$m[3]."\" target=\"_blank\">".$m[1].$m[2].$m[3]."</a>";
    	}
    }
    /*최신글미리보기답글표시*/
    add_filter('kboard_list_where', 'my_kboard_list_where', 10, 3);
    function my_kboard_list_where($where, $board_id, $content_list){
    	if($content_list->is_latest && in_array($board_id, array('2', '3', '4', '5', '6', '7'))){
    		if($content_list->category1){
    			$where = "`board_id`='{$board_id}' AND `category1`='{$content_list->category1}' AND (`status`='' OR `status` IS NULL OR `status`='pending_approval')";
    		}
    		else{
    			$where = "`board_id`='{$board_id}' AND (`status`='' OR `status` IS NULL OR `status`='pending_approval')";
    		}
    	}
    	return $where;
    }
    /*특정글new표시길게*/
    add_filter('kboard_content_is_new', 'my_kboard_content_is_new', 10, 2);
    function my_kboard_content_is_new($is_new, $content){
    	if(in_array($content->uid, array(''))){ // 'uid번호'여러개일때는쉼표로구분함
    		$is_new = true;
    	}
    	return $is_new;
    }
    /*로그인사용자일때작성자입력필드표시시작*/
    add_action('init', 'kboard_comments_field_reshape');
    function kboard_comments_field_reshape(){
    	if(is_user_logged_in()){
    		
    		// 기존 댓글 입력 필드의 출력을 삭제합니다.
    		remove_action('kboard_comments_field', 'kboard_comments_field', 10, 4);
    		
    		// 새로운 댓글 입력 필드를 출력합니다.
    		add_action('kboard_comments_field', 'my_kboard_comments_field', 10, 4);
    	}
    }
    
    
    function my_kboard_comments_field($field_html, $board, $content_uid, $comment_builder){
    	?>
    	<div class="comments-field">
    		<label class="comments-field-label" for="comment_member_display"><?php echo __('Author', 'kboard-comments')?></label>
    		<input type="text" id="comment_member_display" name="member_display" value="" placeholder="<?php echo __('Author', 'kboard-comments')?>..." required>
    	</div>
    	<?php
    }
    
    /*새글과댓글알림기능추가*/
    add_action('kboard_comments_insert', 'my_kboard_comments_insert', 10, 3);
    function my_kboard_comments_insert($comment_uid, $content_uid, $board){
    	$comment = new KBComment();
    	$comment->initWithUID($comment_uid);
    	
    	if(!$board->isAdmin()){
    		if(!class_exists('KBMail')){
    			include_once KBOARD_DIR_PATH . '/class/KBMail.class.php';
    		}
    		$url = new KBUrl();
    		$mail = new KBMail();
    		$mail->to = explode(',', $board->meta->latest_alerts);
    		$mail->title = "댓글이 등록 되었습니다.";
    		$mail->content = $comment->content;
    		$mail->url = $url->getDocumentRedirect($content_uid);
    		$mail->url_name = '페이지로 이동';
    		$mail->send();
    	}
    }
    /*관리자에게만 아이피 표시*/
    add_filter('kboard_document_add_option_value_field_data', 'my_kboard_document_add_option_value_field_data', 10, 3);
    function my_kboard_document_add_option_value_field_data($field, $content, $board){
    	if(isset($field['meta_key']) && $field['meta_key'] == 'ip' && !$board->isAdmin()){
    		return array();
    	}
    	return $field;
    }
    /*승인대기 목록에서 안보이게*/
    add_filter('kboard_list_where', 'my_kboard_list_where', 10, 3);
    function my_kboard_list_where($where, $board_id, $content_list){
    	if(in_array($board_id, array('2', '3', '4', '10'))){
    		$where .= "AND (`status`='' OR `status` IS NULL)";
    	}
    	return $where;
    }

     

  • 해결되었습니다. 감사합니다^^

  • 안녕하세요.

    특정 게시판이 여러 개 일 때는

    아래의 코드처럼 해주시면 됩니다.

    add_filter('kboard_list_where', 'my_kboard_list_where', 10, 3);
    function my_kboard_list_where($where, $board_id, $content_list){
    	if(in_array($board_id, array('1', '2', '3'))){
    		$where .= "AND (`status`='' OR `status` IS NULL)";
    	}
    	return $where;
    }

    in_array에 대한 자세한 내용은 아래의 링크를 참고해보시겠어요?

    http://php.net/manual/kr/function.in-array.php

    고맙습니다.

  • 해결되었습니다.

    다만 게시판 2개를 쓰고 있어요

    customer(id =1),ocean franchise(id =3) 두개인데

    저 코드를 숫자만 바꿔서 두번 넣었더니 error코드 500 이 뜹니다. 

    그래서 중간에 ($board_id == '1')($board_id == '3') 두개 넣어도 똑같구요.

    두 게시판 모두 효과를 보고 싶은데 방법이 있을까요?

  • 안녕하세요.

    테마 편집기 페이지에서 functions.php 파일 업데이트 시 오류 메시지가 표시된다면

    플러그인 충돌 또는 호스팅 문제일 듯합니다.

    모든 플러그인을 비활성화하고 다시 코드를 추가해서 확인해보시겠어요?

    그래도 오류 메시지가 표시되면 호스팅 문제일 수도 있으니 해당 관리자에게 문의해보셔야 할 듯합니다.

    FTP로 접속해서 /wp-content/themes/사용중인테마/functions.php 파일에

    코드를 직접 추가하셔도 됩니다.

     

    실제 게시판 숏코드에서 id가 1이라면

    ($board_id == '1')로 해주시면 됩니다.

    고맙습니다.

  • css코드로는 할 수 없는건가요?

  • 어떠한 글을 써도 저 오류메세지가 뜨네요..

  • 실제 게시판 숏코드가

     

    [kboard id=1] 이어서 수정할 부분을

    ($kboard_id =='1') 이렇게 수정했는데 맞는건가요?

  • 치명적인 에러를 점검하기 위해 사이트와 통신할 수 업습니다. 따라서 PHP 변경사항이 원래의 것으로 복구됐습니다. PHP 파일 변경사항을 SFTP와 같은 다른 수단을 통해 업로드 해야 합니다.

     

    이렇게 나오네요. ㅠ

  • 안녕하세요~^^

    승인 대기 중인 게시글을 목록에서 안 보이게 하시려면

    워드프레스 관리자 -> 외모 -> 테마 편집기 페이지에서 functions.php 파일 하단에

    아래의 코드를 추가해보시겠어요?

    add_filter('kboard_list_where', 'my_kboard_list_where', 10, 3);
    function my_kboard_list_where($where, $board_id, $content_list){
    	if($board_id == '1'){
    		$where .= "AND (`status`='' OR `status` IS NULL)";
    	}
    	return $where;
    }

    위 코드에서 $board_id == '1' 부분은 실제 게시판 id로 수정하신 후에 적용해보세요.

    고맙습니다.

워드프레스 에러 기술지원 서비스 전문가에게 맡기세요