안녕하세요 게시글 작성자 아이피와 댓글 아이피를 관리자만 볼수있게 하고 싶습니다.

전에 여러 코드들을 커뮤니티에서 찾아서 했는데요.

지금은 어제 업데이트 한이후 

게시글은 아이피가 보이는데

댓글 에 아이피가 보이지 않습니다.

그리고 게시글 작성자 아이피와 댓글아이피를 모든 게시판에 관리자만 볼수 있게 하고 싶은데요

어떻게 해야 할까요?

지금 버젼은 이렇습니다 

바빠서 어제 업데이트를 했더니 다 사라져 버렸어요 ㅜㅜ

  • 현재 설치된 게시판 플러그인 버전은 5.5 입니다.
  • 현재 설치된 댓글 플러그인 버전은 4.6 입니다.
좋은 정보와 인맥을 동시에, 워드프레스 사용자 단톡방 참여하기
좋은 정보와 인맥을 동시에, 워드프레스 사용자 단톡방 참여하기
  • 안녕하세요~^^

    최신 버전 KBoard 플러그인에서 댓글 쪽 IP를 관리자만 볼 수 있게 하시려면

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

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

    add_action('kboard_comments_field', 'my_kboard_comments_field', 10, 4);
    function my_kboard_comments_field($field_html, $board, $content_uid, $commentBuilder){
    	if($board->id == '1'){ // 실제 게시판 id로 적용해주세요.
    		?>
    		<input type="hidden" name="comment_option_ip" value="<?php echo kboard_user_ip()?>">
    		<?php
    	}
    }

    위의 코드에서 $board->id == '1' 부분은 실제 게시판 id로 적용해주세요.

    기존에 위의 코드가 추가되어 있다면 생략하고

    FTP로 접속해서 /wp-content/plugins/kboard-comments/skin/사용중인스킨/list-template.php 파일에

    아래의 코드를 찾아서

    <?php echo $comment->getUserDisplay()?>

    찾은 코드 밑에 아래의 코드를 추가해보세요.

    <?php if($board->isAdmin() && $comment->option->ip):?>(<?php echo $comment->option->ip?>)<?php endif?>

     

    KBoard 댓글 플러그인 4.6 이전 버전에서 적용하는 방법은

    아래의 링크를 참고해보세요.

    https://www.cosmosfarm.com/threads/document/37543

    고맙습니다.

  • 제가 원하는것은 일단 모든 게시판과 모든게시물 의 게시물작성자 모든 댓글의 작성자의 아이피를 관리자만 보게 하고 싶습니다.

     

    좀 도와주세요 ㅜㅠ

     

     지금 이렇게 되어 있는데 좀 도와주시면 감사하겠습니다

     

    //아이피주소관리자만 확인
    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_action('kboard_document_insert', 'my_kboard_document_insert', 10, 4);
    function my_kboard_document_insert($content_uid, $board_id, $content, $board){
        { if($board->id == '1')// 실제 게시판 id로 적용해주세요.
            if(!is_user_logged_in()){
                $content->option->ip = kboard_user_ip();
            }
            
            $content->member_display = uniqid();
            $content->updateContent();
        }
    }
    
    add_action('kboard_comments_insert', 'my_kboard_comments_insert', 10, 3);
    function my_kboard_comments_insert($insert_id, $content_uid, $board){
         if($board->id == '1'){ // 실제 게시판 id로 적용해주세요.
            $content = new KBContent();
            $content->initWithUID($content_uid);
            
            $comment = new KBComment();
            $comment->initWithUID($insert_id);
            
            if(is_user_logged_in()){
                if($comment->user_uid == $content->member_uid){
                    $comment->user_display = $content->member_display . ' (작성자)';
                }
            }
            else if($content->option->ip == kboard_user_ip()){
                $comment->user_display = $content->member_display . ' (작성자)';
            }
            $comment->update();
        }
    
    }
    add_action('kboard_comments_field', 'my_kboard_comments_field', 10, 4);
    function my_kboard_comments_field($field_html, $board, $content_uid, $commentBuilder){
    	if($board->id == '1'){ // 실제 게시판 id로 적용해주세요.
    		?>
    		<input type="hidden" name="comment_option_ip" value="<?php echo kboard_user_ip()?>">
    		<?php
    	}
    }
    //스크롤 위로
    add_action('kboard_skin_header', 'my_kboard_skin_header', 10, 1);
    function my_kboard_skin_header($builder){
    	$board = $builder->board;
    	if($board->id == '1'){ 
    		?>
    		<script>
    		jQuery(document).ready(function(){
    			parent.jQuery('html, body').scrollTop(0);
    		});
    		</script>
    		<?php
    	}
    }
    
    
    

     

  • 일단 게시판1 개에 댓글과 게시글에 아이피가 보이기는합니다 하지만 이걸 전체 게시판(공지사항, 자유게시판 등등) 에 적용하려면 어떻게 해야하나요

  • 전체 게시판에 적용하시려면

    올려주신 코드 중 아래에서 생략된 부분만 남기고 지워보시겠어요?

    if($board->id == '1'){
    
    ...
    
    }

    고맙습니다.

  • if($board->id == '1'){
    
    ...
    
    }

    전체 게시판에 적용하시려면

    올려주신 코드 중 아래에서 생략된 부분만 남기고 지워보시겠어요?

     

    라고 말씀하셨는데 잘이해가 가지 않습니다.

    ㅜㅜ

    그리고 비슷한 if 로 시작하는것이 많아서 ㅜㅜ

    정확하게 알려주시면 정말 정말 감사할거 같아요 ~~~!!

  • 특정 게시판이 아닌 모든 게시판에 적용하시려면

    올려주신 코드 중 아래의 코드대신

    // 익명 암호화
    add_action('kboard_document_insert', 'my_kboard_document_insert', 10, 4);
    function my_kboard_document_insert($content_uid, $board_id, $content, $board){
        { if($board->id == '1')// 실제 게시판 id로 적용해주세요.
            if(!is_user_logged_in()){
                $content->option->ip = kboard_user_ip();
            }
            
            $content->member_display = uniqid();
            $content->updateContent();
        }
    }
    
    add_action('kboard_comments_insert', 'my_kboard_comments_insert', 10, 3);
    function my_kboard_comments_insert($insert_id, $content_uid, $board){
         if($board->id == '1'){ // 실제 게시판 id로 적용해주세요.
            $content = new KBContent();
            $content->initWithUID($content_uid);
            
            $comment = new KBComment();
            $comment->initWithUID($insert_id);
            
            if(is_user_logged_in()){
                if($comment->user_uid == $content->member_uid){
                    $comment->user_display = $content->member_display . ' (작성자)';
                }
            }
            else if($content->option->ip == kboard_user_ip()){
                $comment->user_display = $content->member_display . ' (작성자)';
            }
            $comment->update();
        }
    
    }
    add_action('kboard_comments_field', 'my_kboard_comments_field', 10, 4);
    function my_kboard_comments_field($field_html, $board, $content_uid, $commentBuilder){
    	if($board->id == '1'){ // 실제 게시판 id로 적용해주세요.
    		?>
    		<input type="hidden" name="comment_option_ip" value="<?php echo kboard_user_ip()?>">
    		<?php
    	}
    }

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

    // 익명 암호화
    add_action('kboard_document_insert', 'my_kboard_document_insert', 10, 4);
    function my_kboard_document_insert($content_uid, $board_id, $content, $board){
    	if(!is_user_logged_in()){
    		$content->option->ip = kboard_user_ip();
    	}
    	
    	$content->member_display = uniqid();
    	$content->updateContent();
    }
    
    add_action('kboard_comments_insert', 'my_kboard_comments_insert', 10, 3);
    function my_kboard_comments_insert($insert_id, $content_uid, $board){
    	$content = new KBContent();
    	$content->initWithUID($content_uid);
    	
    	$comment = new KBComment();
    	$comment->initWithUID($insert_id);
    	
    	if(is_user_logged_in()){
    		if($comment->user_uid == $content->member_uid){
    			$comment->user_display = $content->member_display . ' (작성자)';
    		}
    	}
    	else if($content->option->ip == kboard_user_ip()){
    		$comment->user_display = $content->member_display . ' (작성자)';
    	}
    	$comment->update();
    }
    add_action('kboard_comments_field', 'my_kboard_comments_field', 10, 4);
    function my_kboard_comments_field($field_html, $board, $content_uid, $commentBuilder){
    	?>
    	<input type="hidden" name="comment_option_ip" value="<?php echo kboard_user_ip()?>">
    	<?php
    }

    고맙습니다.

  • 안녕하세요 

    상위처럼 코드를 변경하였습니다만.. ㅜㅜ

    표기가 안되고 있습니다.

    functions.php

    //아이피주소관리자만 확인
    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_action('kboard_document_insert', 'my_kboard_document_insert', 10, 4);
    function my_kboard_document_insert($content_uid, $board_id, $content, $board){
    	if(!is_user_logged_in()){
    		$content->option->ip = kboard_user_ip();
    	}
    	
    	$content->member_display = uniqid();
    	$content->updateContent();
    }
    
    add_action('kboard_comments_insert', 'my_kboard_comments_insert', 10, 3);
    function my_kboard_comments_insert($insert_id, $content_uid, $board){
    	$content = new KBContent();
    	$content->initWithUID($content_uid);
    	
    	$comment = new KBComment();
    	$comment->initWithUID($insert_id);
    	
    	if(is_user_logged_in()){
    		if($comment->user_uid == $content->member_uid){
    			$comment->user_display = $content->member_display . ' (작성자)';
    		}
    	}
    	else if($content->option->ip == kboard_user_ip()){
    		$comment->user_display = $content->member_display . ' (작성자)';
    	}
    	$comment->update();
    }
    add_action('kboard_comments_field', 'my_kboard_comments_field', 10, 4);
    function my_kboard_comments_field($field_html, $board, $content_uid, $commentBuilder){
    	?>
    	<input type="hidden" name="comment_option_ip" value="<?php echo kboard_user_ip()?>">
    	<?php
    }
    //스크롤 위로
    add_action('kboard_skin_header', 'my_kboard_skin_header', 10, 1);
    function my_kboard_skin_header($builder){
    	$board = $builder->board;
    	if($board->id == '1'){ 
    		?>
    		<script>
    		jQuery(document).ready(function(){
    			parent.jQuery('html, body').scrollTop(0);
    		});
    		</script>
    		<?php
    	}
    }
    
    
    

    이렇게 되어 있구요

     

    list-template.php

    <div class="comments-list">
    	<ul>
    		<?php while($comment = $commentList->hasNext()): $commentURL->setCommentUID($comment->uid);?>
    		<li itemscope itemtype="http://schema.org/Comment" class="kboard-comments-item" data-username="<?php echo $comment->user_display?>" data-created="<?php echo $comment->created?>">
    			<div class="comments-list-username" itemprop="author">
    				<?php echo $comment->getUserDisplay()?>
    				<?php if($board->isAdmin() && $comment->option->ip):?>(<?php echo $comment->option->ip?>)<?php endif?>
    			</div>

    이파일도 요렇게 되어 있는데요..ㅡㅜ

     

    도대체 왜 안될까요

     

    https://imgur.com/NMGrAWG

    이건 원래 작동이 되었던 게시판인데 잘작동 됩니다.

     

    https://imgur.com/L1ht3sn

    요건 코드 수정후 테스트로 해본건데 아이피가 안보이네욤 ㅠㅠ

     

    도와주세요

  • 안녕하세요.

    이미지 사진은 imgur에 업로드한 뒤 링크 걸어주시길 부탁드립니다.

     

    관리자로 로그인해서 확인해보신 건지요?

    해당 코드를 저희 쪽 테스트 서버에서 확인해보니

    관리자로 로그인 시에만 IP 정보가 표시되는 것을 확인했습니다.

    https://imgur.com/a/aoOGNyn

     

    첫번째 이미지는 관리자로 로그인 시 IP가 표시됩니다.

    두번째 이미지는 비로그인 사용자가 게시글을 확인할 때 IP가 표시되지 않습니다.

    고맙습니다.

좋은 정보와 인맥을 동시에, 워드프레스 사용자 단톡방 참여하기