인사이드ASK스킨에서의 글 삭제 금지 방법

Inside-ask 스킨 문의입니다.

사용자가 작성한 글을 사용자 본인이 삭제하지 못하도록 하고 싶습니다.

방법이 있을까요?

좋은 정보와 인맥을 동시에, 워드프레스 사용자 단톡방 참여하기
좋은 정보와 인맥을 동시에, 워드프레스 사용자 단톡방 참여하기
  • 안녕하세요~^^

    KBoard 플러그인에서 관리자를 제외한 다른 사용자들이

    본인이 쓴 글이더라도 삭제하지 못하게 하시려면

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

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

    add_action('kboard_skin_header', 'my_kboard_skin_header', 10, 1);
    function my_kboard_skin_header($board_builder){
    	if($board_builder->board->id == '1' && $board_builder->mod == 'remove' && !$board_builder->board->isAdmin()){
    		$url = new KBUrl();
    		die('<script>alert("'.__('You do not have permission.', 'kboard').'"); history.go(-1);</script>');
    	}
    }

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

    고맙습니다.

  • 외모 → 테마 편집기 페이지에서 functions.php를 볼 수 없습니다.

    다른 방법은 없을까요?

  • 워드프레스 관리자 페이지에서 테마 쪽 functions.php 파일을 수정할 수 없으시다면

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

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

    고맙습니다.

  • 추가해서 테스트를 해보았더니

    해당 게시판 설정 페이지 접근 시 그리고 게시판이 적용된 홈페이지 접근 시
    "'.__('You do not have permission.', 'kboard'"라는 에러 팝업창이 뜨고
    확인 버튼을 누르면 게시판이 적용된 페이지에 접근을 못하고 공백으로 뜹니다.
    (게시판 대시보드에서는 에러 확인버튼 누를 시 설정페이지까지는 접근)

    다시 확인 부탁드립니다.

  • 저희 쪽 테스트 서버에서 올려드린 코드로 확인했을 땐 별 문제없었는데 이상하군요.

    실제 적용하신 코드를 에디터의 코드 스니펫 기능으로 올려주시겠어요?

    고맙습니다.

  • 아래와 같습니다~

    <?php
    /*
    * The function allows us to include deep directory PHP files if they exist in child theme path.
    * Otherwise it works just regularly include main theme files.
    */
    if (!function_exists('nrgbarbershop_file_require')) {
        function nrgbarbershop_file_require($file, $uri = false) {
            $file = str_replace("\\", "/", $file); // Replaces If the customer runs on Win machine. Otherway it doesn't perform
            if (is_child_theme()) {
                if (!$uri) {
                    $dir = str_replace("\\", "/", get_template_directory());
                    $replace = str_replace("\\", "/", get_stylesheet_directory());
                    $file_exist = str_replace($dir, $replace, $file);
                    $file = str_replace($replace, $dir, $file);
                } else {
                    $dir = get_template_directory_uri();
                    $replace = get_stylesheet_directory_uri();
                    $file_exist = str_replace($dir, $replace, $file);
    
                    $file_child_url = str_replace($dir, get_stylesheet_directory(), $file);
                    if( file_exists($file_child_url) ){
                        return $file_exist;
                    }
                }
    
                if( file_exists($file_exist) ){
                    $file_child = str_replace($dir, $replace, $file);
                    return $file_child;
                }
                return $file;
    
            } else {
                return $file;
            }
        }
    }
    
    
    // Theme setup
    if ( ! function_exists( 'nrgbarbershop_theme_setup' ) ) :
        function nrgbarbershop_theme_setup() {
    
            // load translate file
            load_theme_textdomain( 'nrgbarbershop', get_template_directory() . '/languages' );
    
            // Add default posts and comments RSS feed links to head.
            add_theme_support( 'automatic-feed-links' );
    
            // Let WordPress manage the document title.
            add_theme_support( 'title-tag' );
    
            // Enable support for Post Thumbnails on posts and pages.
            add_theme_support( 'post-thumbnails' );
            set_post_thumbnail_size( 860, 290, true );
    
            // Set Image sizes
            add_image_size( 'nrgbarbershop-blog-thumb', 360, 270, true );
            add_image_size( 'nrgbarbershop-project-img', 400, 400, true );
    
            // This theme uses wp_nav_menu() in two locations.
            register_nav_menus( array(
                'primary' => esc_html__('Primary Menu', 'nrgbarbershop'),
                'footer' => esc_html__('Footer Menu', 'nrgbarbershop')
            ) );
    
            // Switch default core markup for search form, comment form, and comments to output valid HTML5.
            add_theme_support( 'html5', array(
                'search-form', 'comment-form', 'comment-list', 'gallery', 'caption'
            ) );
    
            // Enable support for Post Formats.
            add_theme_support( 'post-formats', array(
                'image', 'video', 'quote', 'gallery', 'audio'
            ) );
        }
    endif;
    add_action( 'after_setup_theme', 'nrgbarbershop_theme_setup' );
    
    
    
    // default content width
    if ( ! isset( $content_width ) ) $content_width = 940;
    
    
    
    $nrgbarbershop_sidebars = array();
    
    // Register widget area.
    function nrgbarbershop_widgets_init() {
        
        global $nrgbarbershop_sidebars;
        if(isset($nrgbarbershop_sidebars)) {
            foreach ($nrgbarbershop_sidebars as $id => $sidebar) {
                if( !empty($id) ){
                    if( $id=='sidebar-portfolio' && !class_exists('nrgbarbershop_Portfolio_PT') ){
                        continue;
                    }
    
                    if( $id=='sidebar-woo' && !function_exists('is_shop') ){
                        continue;
                    }
                    
                    register_sidebar(array(
                        'name' => $sidebar,
                        'id' => $id,
                        'description' => esc_html__('Add widgets here to appear in your sidebar.', 'nrgbarbershop'),
                        'before_widget' => '<aside id="%1$s" class="widget %2$s">',
                        'after_widget'  => '</aside>',
                        'before_title'  => '<h3 class="widget-title">',
                        'after_title'   => '</h3>'
                    ));                
                }
            }
        }
    
        // Footer widget areas
        $footer_widget_num = TT::get_mod('footer_style');
    
        for($i=1; $i<=$footer_widget_num ; $i++ ) {
            register_sidebar(
                array(
                    'name'          => esc_html__('Footer Column', 'nrgbarbershop') . ' ' .$i,
                    'id'            => 'footer'.$i,
                    'description'   => esc_html__('Add widgets here to appear in your footer column', 'nrgbarbershop') . ' ' .$i,
                    'before_widget' => '<div id="%1$s" class="footer_widget widget %2$s">',
                    'after_widget'  => '</div>',
                    'before_title'  => '<h3 class="widget-title">',
                    'after_title'   => '</h3>',
                )
            );
        }
    
    
    }
    add_action( 'widgets_init', 'nrgbarbershop_widgets_init' );
    
    
    
    if ( ! function_exists( 'nrgbarbershop_body_class_filter' ) ) :
        function nrgbarbershop_body_class_filter( $classes ) {
            global $post;
            $page_for_posts = get_option('page_for_posts');
            $is_blog_page = is_home() && get_post_type($post) && !empty($page_for_posts) ? true : false;
    
            if( is_page() || $is_blog_page ){
                if(TT::getmeta('remove_padding')) {
                    $classes[] = 'no-content-padding';
                }
    
                if($is_blog_page){
                    $post = get_post($page_for_posts);
                }
                
                if( TT::getmeta('one_page_menu', $post->ID)=='1' ){
                    $classes[] = "one-page-menu";
                }
    
            }
    
            $classes[] = "left-side-menu";
    
            return $classes;
        }
    endif;
    add_filter( 'body_class', 'nrgbarbershop_body_class_filter' );
    
    
    
    if ( ! function_exists( 'nrgbarbershop_fonts_url' ) ) :
        function nrgbarbershop_fonts_url() {
            $fonts_url = '';
            $fonts     = array();
            $subsets   = 'latin,latin-ext';
    
            $fonts[] = 'Maven+Pro:400,700,500';
            $fonts[] = 'Lato:400,100,100italic,300,300italic,400italic,700,700italic,900,900italic';
    
            if ( $fonts ) {
                $fonts_url = esc_url(add_query_arg( array(
                    'family' => implode( '|', $fonts ),
                    'subset' => urlencode( $subsets ),
                ), '//fonts.googleapis.com/css' ));
            }
    
            return $fonts_url;
        }
    endif;
    
    
    
    if( ! function_exists('nrgbarbershop_enqueue_scripts') ) :
        function nrgbarbershop_enqueue_scripts() {
            wp_enqueue_script( 'wp-mediaelement' );
    
            if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) {
                wp_enqueue_script( 'comment-reply' );
            }
    
            // Add custom fonts, used in the main stylesheet.
            wp_enqueue_style( 'nrgbarbershop-fonts', nrgbarbershop_fonts_url(), array(), null );
    
            wp_enqueue_style( 'bootstrap', get_template_directory_uri() . '/css/bootstrap.min.css' );
            wp_enqueue_style( 'fontawesome', get_template_directory_uri() . '/css/font-awesome.min.css' );
            wp_enqueue_style( 'theme-stylesheet', get_stylesheet_uri() );
    
            wp_enqueue_script( 'swiper', get_template_directory_uri() . '/js/idangerous.swiper.min.js', false, false, true );
            wp_enqueue_script( 'isotope', get_template_directory_uri() . '/js/isotope.pkgd.min.js', false, false, true );
            wp_enqueue_script( 'magnific', get_template_directory_uri() . '/js/magnific.js', false, false, true );
            wp_enqueue_script( 'placeholder', get_template_directory_uri() . '/js/placeholder.min.js', false, false, true );
            wp_enqueue_script( 'countTo', get_template_directory_uri() . '/js/jquery.countTo.js', false, false, true );
            wp_enqueue_script( 'global', get_template_directory_uri() . '/js/global.js', array('jquery'), false, true );
    
        }
    endif;
    add_action( 'wp_enqueue_scripts', 'nrgbarbershop_enqueue_scripts' );
    
    
    
    if( ! function_exists('nrgbarbershop_custom_excerpt_length') ) :
        function nrgbarbershop_custom_excerpt_length( $length ) {
            return 20;
        }
    endif;
    add_filter( 'excerpt_length', 'nrgbarbershop_custom_excerpt_length', 999 );
    
    
    
    if( ! function_exists('nrgbarbershop_custom_excerpt_more') ) :
        function nrgbarbershop_custom_excerpt_more( $excerpt ) {
            return ' ...';
        }
    endif;
    add_filter( 'excerpt_more', 'nrgbarbershop_custom_excerpt_more' );
    
    
    
    if( ! function_exists('nrgbarbershop_mime_types') ) :
        function nrgbarbershop_mime_types($mime_types){
            $mime_types['svg'] = 'image/svg+xml';
            return $mime_types;
        }
    endif;
    add_filter('upload_mimes', 'nrgbarbershop_mime_types', 1, 1);
    
    
    
    if( ! function_exists('nrgbarbershop_print_main_menu') ) :
        function nrgbarbershop_print_main_menu($menu_class = ''){
            global $post;
            $po = $post;
            $page_for_posts = get_option('page_for_posts');
            $is_blog_page = is_home() && get_post_type($post) && !empty($page_for_posts) ? true : false;
            if( (is_page() || $is_blog_page) && $is_blog_page )
                $po = get_post($page_for_posts);
    
            if( isset($po->ID) && TT::getmeta('one_page_menu', $po->ID)=='1' ){
                $content = $po->post_content;
                $pattern = get_shortcode_regex();
    
                echo "<ul class='$menu_class'>";
                if( preg_match_all( '/'. $pattern .'/s', $post->post_content, $matches ) && array_key_exists( 2, $matches ) && in_array( 'vc_row', $matches[2] ) ){
                    foreach ($matches[3] as $attr) {
                        $props = array();
                        $sarray = explode('" ', trim($attr));
                        foreach ($sarray as $val) {
                            $el =explode("=", $val);
                            $s1 = str_replace('"', '', trim($el[0]));
                            if( isset($el[1]) ){
                                $s2 = str_replace('"', '', trim($el[1]));
                                $props[$s1] = $s2;
                            }
                        }
    
                        $op_section = isset($props['one_page_section']) ? $props['one_page_section'] : '';
                        $label = isset($props['one_page_label']) ? $props['one_page_label'] : '';
                        $slug = isset($props['one_page_slug']) ? $props['one_page_slug'] : '';
                        $data_icon = '';
    
                        if( $op_section!="yes" ){ continue; }
                        if( empty($label) ){ continue; }
    
                        
                        $icon_type = isset($props['op_icon_type']) ? $props['op_icon_type'] : '';
                        $icon = isset($props['one_page_icon']) ? $props['one_page_icon'] : '';
                        $img = isset($props['one_page_image']) ? $props['one_page_image'] : '';
    
                        if( $icon_type=='icon_image' ){
                            $image_src = !empty($img) ? wp_get_attachment_image_src($img, 'thumbnail') : '';
                            $data_icon = !empty($image_src) ? "<img src='$image_src[0]'>" : '';
                        }
                        else{
                            $data_icon = !empty($icon) ? "<i class='$icon'></i>" : '';
                        }
                    
    
                        if( isset($po->ID) && TT::getmeta('one_page_menu', $po->ID)=='1' ){
                            $content = $po->post_content;
                            $pattern = get_shortcode_regex();
                                                    echo "<li class='menu-item'><a class='scroll-to-link' href='".esc_attr($slug)."'>$data_icon $label</a></li>";
    
                        }
                    }
                } 
        if (function_exists('icl_get_languages')) {
                    $languages = icl_get_languages('skip_missing=0');
                      
                    if(1 < count($languages)){
                     
                        foreach($languages as $l) {
                            if($l['active'] != 1) {
                                $subitems .= '<li class="menu-item lang-'.$l['country_flag_url'].'"><a href="'.$l['url'].'"><img src="'.$l['country_flag_url'].'" height="12" alt="'.$l['language_code'].'" width="18" /> '.'</a></li>';
                            }
                        } 
                        echo $subitems; 
                    } 
                   }  
    
                echo "</ul>";
            }
            else{
                wp_nav_menu( array(
                    'menu_id'           => 'primary-nav',
                    'menu_class'        => $menu_class,
                    'theme_location'    => 'primary',
                    'container'         => '',
                    'fallback_cb'       => 'nrgbarbershop_primary_callback'
                ) );
            }
        }
    endif;
    
    
    
    // Primary menu callback & it prints one page menu if current page specified
    if ( ! function_exists( 'nrgbarbershop_primary_callback' ) ) :
        function nrgbarbershop_primary_callback(){
            echo '<ul>';
            wp_list_pages( array(
                'sort_column'  => 'menu_order, post_title',
                'title_li' => '') );
            echo '</ul>';
        }
    endif;
    
    
    
    // Footer menu callback
    if ( ! function_exists( 'nrgbarbershop_footer_callback' ) ) :
        function nrgbarbershop_footer_callback(){
            echo '<nav class="ftr-nav f-ftr-nav clearfix">';
            echo '<ul>';
            wp_list_pages( array(
                'sort_column'  => 'menu_order, post_title',
                'title_li' => '',
                'depth' => 1) );
            echo '</ul>';
            echo '</nav>';
        }
    endif;
    
    
    
    if( !function_exists('wp_site_icon') ) :
        add_action('wp_head', 'nrgbarbershop_print_favicon');
        if ( ! function_exists( 'nrgbarbershop_print_favicon' ) ) :
            function nrgbarbershop_print_favicon(){
                if(TT::get_mod('favicon') != '')
                    echo '<link rel="shortcut icon" type="image/x-icon" href="'.TT::get_mod('favicon').'"/>';
            }
        endif;
    endif;
    
    
    
    /*
    
     _____ _                 _              _____ _                     
    |_   _| |_ ___ _____ ___| |_ ___ ___   |     | |___ ___ ___ ___ ___ 
      | | |   | -_|     | -_|  _| . |   |  |   --| | .'|_ -|_ -| -_|_ -|
      |_| |_|_|___|_|_|_|___|_| |___|_|_|  |_____|_|__,|___|___|___|___|
    
    */
    
    // Themeton Standard Package
    require_once nrgbarbershop_file_require(get_template_directory() . '/framework/classes/class.themeton.std.php');
    
    // Less Compiler
    require_once nrgbarbershop_file_require(get_template_directory() . '/framework/classes/class.less.php');
    
    // Meta fields for Posts
    require_once nrgbarbershop_file_require(get_template_directory() . '/framework/classes/class.render.meta.php');
    require_once nrgbarbershop_file_require(get_template_directory() . '/framework/classes/class.meta.post.php');
    require_once nrgbarbershop_file_require(get_template_directory() . '/framework/classes/class.meta.page.php');
    require_once nrgbarbershop_file_require(get_template_directory() . '/framework/classes/class.meta.portfolio.php');
    
    // WP Customizer
    require_once nrgbarbershop_file_require(get_template_directory() . '/framework/classes/class.wp.customize.controls.php');
    require_once nrgbarbershop_file_require(get_template_directory() . '/framework/classes/class.wp.customize.php');
    require_once nrgbarbershop_file_require(get_template_directory() . '/framework/functions/functions.customizer.php');
    
    // Import functions
    require_once nrgbarbershop_file_require(get_template_directory() . '/framework/functions/functions.for.theme.php');
    require_once nrgbarbershop_file_require(get_template_directory() . '/framework/functions/functions.breadcrumb.php');
    
    // Import Demo Data
    require_once nrgbarbershop_file_require(get_template_directory() . '/framework/classes/class.import.data.php');
    
    // Import Menu
    require_once nrgbarbershop_file_require(get_template_directory() . '/framework/widgets/init_widget.php');
    
    // TGM Plugin Activation
    require_once nrgbarbershop_file_require(get_template_directory() . '/framework/functions/plugin-install.php');
    
    // Include current theme customize
    require_once nrgbarbershop_file_require(get_template_directory() . '/framework/current/functions.php');
    
    // Import Template tags
    require_once nrgbarbershop_file_require(get_template_directory() . '/framework/current/template-tags.php');
    ?>
    
    add_action('kboard_skin_header', 'my_kboard_skin_header', 10, 1);
    function my_kboard_skin_header($board_builder){
    	if($board_builder->board->id == '1' && $board_builder->mod == 'remove' && !$board_builder->board->isAdmin()){
    		$url = new KBUrl();
    		die('<script>alert("'.__('You do not have permission.', 'kboard').'"); history.go(-1);</script>');
    	}
    }

     

  • 안녕하세요.

    워드프레스의 action은 PHP 코드 내에서 실행이 되어야 합니다.

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

    // Import Template tags
    require_once nrgbarbershop_file_require(get_template_directory() . '/framework/current/template-tags.php');
    ?>
    
    add_action('kboard_skin_header', 'my_kboard_skin_header', 10, 1);
    function my_kboard_skin_header($board_builder){
    	if($board_builder->board->id == '1' && $board_builder->mod == 'remove' && !$board_builder->board->isAdmin()){
    		$url = new KBUrl();
    		die('<script>alert("'.__('You do not have permission.', 'kboard').'"); history.go(-1);</script>');
    	}
    }

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

    // Import Template tags
    require_once nrgbarbershop_file_require(get_template_directory() . '/framework/current/template-tags.php');
    
    add_action('kboard_skin_header', 'my_kboard_skin_header', 10, 1);
    function my_kboard_skin_header($board_builder){
    	if($board_builder->board->id == '1' && $board_builder->mod == 'remove' && !$board_builder->board->isAdmin()){
    		$url = new KBUrl();
    		die('<script>alert("'.__('You do not have permission.', 'kboard').'"); history.go(-1);</script>');
    	}
    }
    ?>

    또는 아래의 코드처럼 ?> 부분을 지우셔도 됩니다.

    ​// Import Template tags
    require_once nrgbarbershop_file_require(get_template_directory() . '/framework/current/template-tags.php');
    
    add_action('kboard_skin_header', 'my_kboard_skin_header', 10, 1);
    function my_kboard_skin_header($board_builder){
    	if($board_builder->board->id == '1' && $board_builder->mod == 'remove' && !$board_builder->board->isAdmin()){
    		$url = new KBUrl();
    		die('<script>alert("'.__('You do not have permission.', 'kboard').'"); history.go(-1);</script>');
    	}
    }

    고맙습니다.

  • 적용하였습니다.
    문제가 생길 시 다시 한 번 여쭤보겠습니다.  : )

    혹시 다른 게시판에도 적용을 할려면 위의 코드문을 추가 작성해서 게시판 ID번호만 다르게 입력해야 하나요?

  • KBoard 플러그인에서 여러 개의 게시판에 적용하시려면

    아래의 코드를 활용해보시겠어요?

    add_action('kboard_skin_header', 'my_kboard_skin_header', 10, 1);
    function my_kboard_skin_header($board_builder){
    	if(in_array($board_builder->board->id, array('1', '2', '3')) && $board_builder->mod == 'remove' && !$board_builder->board->isAdmin()){
    		$url = new KBUrl();
    		die('<script>alert("'.__('You do not have permission.', 'kboard').'"); history.go(-1);</script>');
    	}
    }

    위의 코드에서 array('1', '2', '3') 부분을 array('1', '2', '3', '4', '5') 이런 식으로 더 추가하실 수도 있습니다.

    고맙습니다.

  • 빠른 답변 감사합니다!

    추가 도움이 필요할 시 다시 요청드리겠습니다.  : )

  • 본 글의 피드백처럼 문제없이 잘 사용하고 있었는데
    얼마전부터 작동이 안됩니다.

    그래서 다시 본 글을 확인하고 조치를 했는데
    아래와 같은 에러메시지가 뜨면서 아예 사이트 접속이 되지 않습니다.

    "페이지가 작동하지 않습니다."

    원래 질문은 사용자들이 게시판에서
    자신들이 작성한 글을 스스로 삭제할 수 없도록
    하는 방법에 대해서 여쭈었었습니다.

    피드백 부탁드립니다.

  • 안녕하세요.

    올려주신 내용만으로는 원인을 파악하기 어렵습니다.

    디버그 모드를 활성화해서 에러 메시지가 표시되는지 확인해보시겠어요?

    워드프레스 에러 확인하기 - 디버그 모드 활성화 방법

     

    테마나 다른 플러그인 쪽의 문제인지 점검해보셔야 할 듯합니다.

    잠시 다른 테마로 바꿔서 확인해보시고

    다른 플러그인을 하나씩 비활성화해가면서 확인해보시겠어요?

    고맙습니다.

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