CoursePress – redirect to a different page when course completed

1) How can I when user completed all the modules 100%, re-direct them to the ‘Grades’ page instead of just going to the Workbook.

2) Is it not possible to then email this page to them in PDF format

OR

Just add a ‘Print Result Report’ Button?

Thank you

  • Jude
    • DEV MAN

    Hi Tony

    Hope you are doing great.

    1) How can I when user completed all the modules 100%, re-direct them to the ‘Grades’ page instead of just going to the Workbook.

    This can easily be done by hooking to the action shown below

    if( $this->is_course_complete() ) {
    do_action( 'coursepress_set_course_completed', $this->student_id, $this->id );
    }

    2) Is it not possible to then email this page to them in PDF format

    OR

    Just add a ‘Print Result Report’ Button?

    This is not possible out of the box, but looks like an easy to do sub project if you are interested in having it custom developed.

    Cheers

    Jude

  • Jude
    • DEV MAN

    Hi there Tony,

    Here is some code for you. You can copy/paste it either in your functions.php or a site specific theme if you use one.

    add_action(' coursepress_set_course_completed ' , 'my_custom_redirect' , 10 , 2) ;

    function my_custom_redirect ( student_id , course_id ) {
    $location = "www.mycourse.com/grades" ;
    wp_safe_redirect( $location, 200 ) ;
    }

    Replace $location with your own url

    Cheers

    Jude

  • Jude
    • DEV MAN

    Hi there @tony

    Sorry that it happened, it looks like a copy/paste issue. Can you try this code, put your email here and tell me if you get an email when you complete the course.

    add_action(' coursepress_set_course_completed ' , 'my_custom_redirect' , 10 , 2) ;

    function my_custom_redirect ( student_id , course_id ) {
    wp_mail( "youremail@mail.com", "Redirect Triggers", "It Works" );
    $location = "www.mycourse.com/grades" ;
    wp_safe_redirect( $location, 200 ) ;
    }

    Im just checking where the issue lies hook triggers / $location variable / redirect itself.

    Cheers

    Jude

  • Jude
    • DEV MAN

    Hi there Tony,

    This is taking too long back and forth, Please send in

    Subject: “Attn: Jude Rosario

    – WordPress super admin/ admin username + password

    – FTP credentials (host/username/password)

    – cPanel details

    – phpMyAdmin details ( To check database )

    -link back to this thread for reference

    Select “I have a different question” for your topic – this and the subject line ensure that it gets assigned to me :slight_smile:

    https://premium.wpmudev.org/contact/

  • David
    • WPMU DEV Initiate

    Although this is an old topic, I have recently been looking for the same functionality: to send emails to teacher(s) and student upon course completion.

    I came across this post in my research and used the coursepress_set_course_completed hook, however, I discovered that if I viewed the Courses page (where the list of courses are) when logged in as a student, the coursepress_set_course_completed hook would trigger. I only need to catch the course completion once, so having this trigger when viewing a page was an undesired outcome.

    I did some research into the coursepress_set_course_completed hook and came across the add_course_completed_meta function which is run by this hook. Within this function lies another hook coursepress_student_course_completed. This hook has the following comment: Will only fire once when a course is marked as complete, should not trigger again.

    Bingo! Exactly what I was looking for. Now when a course is completed by a student, the coursepress_student_course_completed is triggered and my custom function can run to send out the required emails.

    Hope this helps anyone else looking for similar functionality.

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.