Force certificate creation

If we create an informative course without any "Assessable" module or any question, just text and video modules, at the end of the course there will no be a certificate.

Is there any way to force CoursePress to generate a certificate?

  • Nahid

    Hey Pablo Gonzalez !
    Hope you are having a great day!

    This request has been escalated to our Second Level Support team. They'll be back to us with confirmations if something like this is possible within CoursePress Pro, clues and workarounds (if possible) in this ticket (or we'll be updating the ticket as soon as we hear back from them internally). Please note that the response time of the Second Level Support team might be a bit delayed than that of the general support staff. We really appreciate your patience and consideration regarding this.

    Kind regards,
    Nahid

  • Ivan

    Hi Pablo Gonzalez !

    You could try adding the following snippet in a MU plugin ( more info about MU plugins is here )

    <?php
    function wpmu_coursepress_generate_sertificates( $wp ) {
    	if ( class_exists( 'CoursePress_Data_Course' ) && !empty( $wp->query_vars['course_completion'] ) ) {
    		$cp				 = (object) array(
    					'student_id' => get_current_user_id(),
    		);
    		$cp->course_id	 = CoursePress_Data_Course::by_name( '', true );
    		$cp->is_enrolled = CoursePress_Data_Course::student_enrolled(
    						$cp->student_id, $cp->course_id
    		);
    		$student_progress	 = CoursePress_Data_Student::get_completion_data( $cp->student_id, $cp->course_id );
    		$is_course_completed = CoursePress_Data_Student::is_course_complete( $cp->course_id, $cp->student_id, $student_progress );
    
    		if ( 555 == $cp->course_id && $cp->is_enrolled && !$is_course_completed ) {
    			$student_progress	 = CoursePress_Helper_Utility::set_array_value(
    					$student_progress, 'completion/completed', true
    			);
    			CoursePress_Data_Student::update_completion_data(
    				$cp->student_id,
    				$cp->course_id,
    				$student_progress
    			);
    
    			do_action(
    					'coursepress_student_course_completed', $cp->student_id, $cp->course_id, get_post_field( 'post_title', $cp->course_id )
    			);
    
    			CoursePress_Data_Certificate::generate_certificate(
    					$cp->student_id, $cp->course_id
    			);
    		}
    	}
    }
    add_action( 'parse_request', 'wpmu_coursepress_generate_sertificates', 9 );

    Note: you should replace 555 to your real course id - you can see it here

    Best,
    Ivan.

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.