KBoard 댓글에 서식이 메일로 오지 않습니다.

KBoard 댓글에 서식이 메일로 오지 않습니다.

 

                   <div class="comments-field">
                        <label class="comments-field-label"> 지원분류 : </label>
                        <input type="checkbox" name="comment_option_stype1" value="방문">방문
                           <input type="checkbox" name="comment_option_stype2" value="원격">원격
                           <input type="checkbox" name="comment_option_stype3" value="대기">대기
                           <input type="checkbox" name="comment_option_stype4" value="유선">유선
                    </div>
                           
        
                   <div class="comments-field">
                        <label class="comments-field-label"> 지원종류 : </label>
                        <input type="checkbox" name="comment_option_skinds1" value="정기점검">정기점검
                           <input type="checkbox" name="comment_option_skinds2" value="장애지원">장애지원
                           <input type="checkbox" name="comment_option_skinds3" value="기술지원">기술지원
                    </div>

 

 

==========

               <?php $stype1=$comment->option->stype1?>
               <?php $stype2=$comment->option->stype2?>
               <?php $stype3=$comment->option->stype3?>
               <?php $stype4=$comment->option->stype4?>


               <?php if( !empty($stype1 )){
                   echo __('지원분류 : ', 'kboard') ;
                   $mail_stype='지원분류 :';
               }elseif( !empty($stype2 )){
                   echo __('지원분류 : ', 'kboard') ;
                   $mail_stype='지원분류 :';
               }elseif( !empty($stype3 )){
                   echo __('지원분류 : ', 'kboard') ;
                   $mail_stype='지원분류 :';
               }elseif( !empty($stype4 )){
                   echo __('지원분류 : ', 'kboard') ;
                   $mail_stype='지원분류 :';
               }?>              

                <?php if( !empty($stype1 )){
                    echo $comment->option->stype1;
                    $mail_stype .=$stype1 ;
               }
               if( !empty($stype2 )){
                   echo $comment->option->stype2;
                   $mail_stype .=$stype2 ;
               }
               if( !empty($stype3 )){
                   echo $comment->option->stype3;
                   $mail_stype .=$stype3 ;
               }
               if( !empty($stype4 )){
                   echo $comment->option->stype4;
                   $mail_stype .=$stype4 ;
               }
               echo("<br>")

               ?>                
               
               <?php $skinds1=$comment->option->skinds1?>
               <?php $skinds2=$comment->option->skinds2?>
               <?php $skinds3=$comment->option->skinds3?>
               <?php $skinds4=$comment->option->skinds4?>


            <?php if( !empty($skinds1 )){
                   echo __('지원종류 : ', 'kboard') ;
               }elseif( !empty($skinds2 )){
                   echo __('지원종류 : ', 'kboard') ;
               }elseif( !empty($skinds3 )){
                   echo __('지원종류 : ', 'kboard') ;
               }elseif( !empty($skinds4 )){
                   echo __('지원종류 : ', 'kboard') ;
               }?>              

            <?php if( !empty($skinds1 )){
                    echo $comment->option->skinds1;
               }
               if( !empty($skinds2 )){
                   echo $comment->option->skinds2;
               }
               if( !empty($skinds3 )){
                   echo $comment->option->skinds3;
               }
               if( !empty($skinds4 )){
                   echo $comment->option->skinds4;
               }
               echo("<br>")           
               ?>                 

 

=====

여기까지는 완벽한데 ....내용이 메일로 전송하면 텍스트 박스에 있는 내용만 발송돼는데. 위에 서식 내용도 받을수 있을까요?

항상 감사합니다.

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

    프로그램 코드는 글쓰기 에디터에 있는 "코드 스니펫 삽입" 기능으로 올려주시길 부탁드립니다.

     

    아마도 알림이 전송되도록 추가한 코드에 내용만 전송되도록 되어있을 듯합니다.

    해당 코드에 내용과 함께 추가한 서식의 데이터가 보내지도록 코드를 수정하셔야 할 듯합니다.

    우선 알림이 전송되도록 테마의 functions.php 파일에 추가하신 코드도 함께 올려주시겠어요?

    도움을 드릴 수 있을지 확인해보겠습니다.

    고맙습니다.

  • <?php
    //if(!function_exists('my_kboard_email_alerts')){
        add_action('kboard_comments_insert', 'my_kboard_email_alerts', 10, 2);
        function my_kboard_email_alerts($comment_uid, $content_uid){
            $comment = new KBComment();
            $comment->initWithUID($comment_uid);
            
            $content = new KBContent();
            $content->initWithUID($content_uid);
            
            $email = explode(',', $content->option->email);
            
            

            if($email){
                if(!class_exists('KBMail')){
                    include_once KBOARD_DIR_PATH . '/class/KBMail.class.php';
                }
    //댓글입력자  20180904
                $comment_author = new WP_User(get_current_user_id());
                
                $mail_content = '작 성 자 : ' . $comment_author->display_name . '<br>';

                $mail_content .= $comment->content;
    //입력자            
                $url = new KBUrl();
                $mail = new KBMail();
                
    //            $mail->to = $user->user_email;
                $mail->to = $email;
                $mail->title = "[댓글알림] {$content->title}";
                $mail->content = $mail_content;
    //            $mail->content = $comment->content;
                $mail->url = $url->getDocumentRedirect($content->uid);
                $mail->url_name = __('Go to Homepage', 'kboard');
                $r = $mail->send();
            }
        }
    //}

     

    ========

    dd_action('kboard_comments_insert', 'my_kboard_comments_insert', 10, 2);
    function my_kboard_comments_insert($insert_id, $content_uid){
        $comment = new KBComment();
        $comment->initWithUID($insert_id);
        $document = new KBContent();
        $document->initWithUID($content_uid);
        
        if($document->member_uid){
            $user = new WP_User($document->member_uid);
            
            if($user->user_email && $user->ID != get_current_user_id()){
                if(!class_exists('KBMail')){
                    include_once KBOARD_DIR_PATH . '/class/KBMail.class.php';
                }
                
                $comment_author = new WP_User(get_current_user_id());
                
                $mail_content = '작성자 : ' . $comment_author->display_name . '<br>';
                $mail_content .= $comment->content;
                
                $url = new KBUrl();
                $mail = new KBMail();
                $mail->to = $user->user_email;
                $mail->title = "[Portal 댓글] {$document->title}";
                $mail->content = $mail_content;
                $mail->url = $url->getDocumentRedirect($document->uid);
                $mail->send();
            }
        }
    }


    @ini_set( 'upload_max_size' , '100M' );
    @ini_set( 'post_max_size', '100M');
    @ini_set( 'max_execution_time', '300' );

    function redirect_to_front_page() {
          global $redirect_to;
          if (!isset($_GET['redirect_to'])) {
                   $redirect_to = get_option('siteurl');
          }
    }
    add_action('login_form','redirect_to_front_page');


    add_filter('kboard_latest_alerts_message', 'my_kboard_latest_alerts_message', 10, 2);
    function my_kboard_latest_alerts_message($mail_content, $content){
        $mail_content = '작 성 자 : '. $content->member_display .'<br><br>' . $mail_content;
        return $mail_content;
    }

     

     

    ==========

    두개입니다.

  • 첫번째 skin 에 포함된 function.php 이고 아래는 테마에 function.php 입니다.

     

  • 안녕하세요.

    두 코드 중 실제 적용되는 코드는 어떤 코드이신지요?

    테마 쪽에 추가하신 코드로 설명을 드리겠습니다.

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

    $mail_content = '작성자 : ' . $comment_author->display_name . '<br>';

    찾은 코드 밑에 아래의 코드를 추가해보시겠어요?

    if(isset($_POST['comment_option_stype1']) && $_POST['comment_option_stype1']){
    	$mail_content .= '지원분류  : ' . $_POST['comment_option_stype1'];
    }

    위와 같이 코드를 추가하시면 댓글 작성 시

    지원분류의 방문 체크박스를 체크하면 메일에 해당 체크박스의 내용도 포함되어 전송합니다.

    다른 필드들도 위와 같이 적용해보시겠어요?

    고맙습니다.

  • 감사합니다. 그런데 그건 잘돼는데..

    list.php

     

                <div class="attr-value">
                    <div class="calendar-event-start-date-set">
                        <input type="text"  style="width: 80px;" class="datepicker" id="comment_option_start_date" name="comment_option_start_date" onchange="kboard_set_start_date(this.value)" value="<?php echo $comment->option->startdate ? $content->option->start_date : (isset($ymd) ? $ymd : $today)?>" title="<?php echo __('Start Date Setting', 'kboard-cross-calendar')?>" readonly>
                        <input type="text"  style="width: 50px;"  class="timepicker" name="comment_option_start_time" maxlength="5" value="<?php echo $comment->option->start_time ? $comment->option->start_time : date('H:i', strtotime('9:00'))?>" title="<?php echo __('Start Time Setting', 'kboard-cross-calendar')?>">
                        ~
                        <input type="text"  style="width: 80px;"  class="datepicker" id="comment_option_end_date" name="comment_option_end_date" onchange="kboard_end_date_check(this.value)" value="<?php echo $comment->option->end_date ? $comment->option->end_date : (isset($ymd) ? $ymd : $today)?>" title="<?php echo __('End Date Setting', 'kboard-cross-calendar')?>" readonly>
                        <input type="text" style="width: 50px;"  class="timepicker" name="comment_option_end_time" maxlength="5" value="<?php echo $comment->option->end_time ? $comment->option->end_time : date('H:i', strtotime('18:00'))?>" title="<?php echo __('End Time Setting', 'kboard-cross-calendar')?>">

                    </div>
                        
                </div>

     

    function.php

     

                if(isset($_POST['comment->option->start_date']) && $_POST['comment->option->start_date']){
                    $mail_content .= '지원시간 :' . $_POST['comment->option->start_date'];
                }
                if(isset($_POST['comment->option->start_time']) && $_POST['comment->option->start_time']){
                    $mail_content .=  $_POST['comment->option->start_time'];
                }
                $mail_content .= ' ~ ';
                if(isset($_POST['comment->option->end_date']) && $_POST['comment->option->end_date']){
                    $mail_content .=  $_POST['comment->option->end_date'];
                }
                if(isset($_POST['comment->option->end_time']) && $_POST['comment->option->end_time']){
                    $mail_content .=  $_POST['comment->option->end_time'];
                }

     

     

     

    시간은 전송돼지 않는 문제가 있습니다.

     

    감사합니다.

     

     

     

     

  • 코드를 올려주실 땐 에디터의 "코드 스니펫 삽입" 기능으로 삽입해주세요. 

    그렇지 않으면 코드가 이상해져서 에러 나는 코드로 바뀌거나,

    질의응답 시 의사소통에 오해와 문제가 생길 수도 있기 때문입니다.

     

    테마 쪽 functions.php 파일에 추가하신 코드가 잘못된 듯합니다.

    $_POST['comment->option->start_date'] 부분을 $_POST['comment_option_start_date']로 변경해보시겠어요?

    start_time, end_date, end_time 모두 교체해보세요.

    고맙습니다.

  • 고맙습니다.

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