Support » Plugin: Tutor LMS - eLearning and online course solution » Issues in Course Attachments add-on

  • Resolved vandung93

    (@vandung93)


    Hello @team.

    There are some issues related to Course Attachments add-on. Please check & fix it.

    1. When this add-on is not activated. It still create post meta record in Database: http://prntscr.com/11eyvbg

    2. Redundancy hook/action to make code run twice times:

    This is your code:

    add_action('save_post_'.$this->course_post_type, array($this, 'save_course_meta'));
    add_action('save_post', array($this, 'save_course_meta'));

    It should be like:
    add_action('save_post', array($this, 'save_course_meta'));

    hook/action ‘save_post’ working for Courses/Lessons/Quiz/Questions..
    No need hook ‘save_post_’.$this->course_post_type anymore.

    3. When attachments is empty. It should not save meta in Database. It will make Database so heavy by time: http://prntscr.com/11eyvbg

    This is your code:

    $attachments = array();
    $attachments_main_edit = tutils()->avalue_dot('_tutor_attachments_main_edit', $_POST);
    if($attachments_main_edit) {
        if ( !empty($_POST['tutor_attachments']) ) {
            $attachments = tutils()->sanitize_array($_POST['tutor_attachments']);
            $attachments = array_unique($attachments);
        }
        update_post_meta($post_ID, '_tutor_attachments', $attachments);
    }

    It should be like:

    $attachments = array();
    $attachments_main_edit = tutils()->avalue_dot('_tutor_attachments_main_edit', $_POST);
    if($attachments_main_edit) {
        if ( !empty($_POST['tutor_attachments']) ) {
            $attachments = tutils()->sanitize_array($_POST['tutor_attachments']);
            $attachments = array_unique($attachments);
        }
    			
        if ( !empty($attachments) ) {
            update_post_meta($post_ID, '_tutor_attachments', $attachments);	
        } else {
            delete_post_meta($post_ID, '_tutor_attachments');
        }			
    }
    • This topic was modified 1 month ago by vandung93.
    • This topic was modified 1 month ago by vandung93.
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.