Hey Dave,
This is going to be more complex than, there is a filter that you should be able to use for this, I’ve tested the following code and it works fine for me, please try adding the following code to your theme functions.php (Ideally you’d want it in your child theme functions.php or added as a mu-plugin so you’re safe when you update the theme)
add_filter( 'coursepress_enroll_button', 'wpmudev_coursepress_enroll_button', 10, 3 );
function wpmudev_coursepress_enroll_button( $button, $course, $student ){
if ( is_single() || is_page() ) return $button;
global $coursepress, $enrollment_process_url, $signup_url;
ob_start();
?>
<form name="enrollment-process" method="post" action="<?php echo $enrollment_process_url ?>">
<button class="apply-button signup " data-link-old="<?php esc_url( $signup_url . '?course_id=' . $course->id ); ?>" data-course-id="<?php echo $course->id; ?>">Signup!</button>
<?php wp_nonce_field( 'enrollment_process' ); ?>
<input name="course_id" value="<?php echo $course->id; ?>" type="hidden"></form>
<?php
$button = ob_get_clean();
if( is_user_logged_in() ){
$student = new Student( get_current_user_id() );
if( $student->user_enrolled_in_course($course->id) ){
$button = '<button class="apply-button apply-button-enrolled " data-link="' . trailingslashit( get_permalink( $course->id ) ) . trailingslashit( $coursepress->get_units_slug() ) . '">Continue Learning</button>';
}else{
ob_start();
?>
<form name="enrollment-process" method="post" action="<?php echo $enrollment_process_url ?>">
<button class="apply-button enroll " data-link-old="<?php esc_url( $signup_url . '?course_id=' . $course->id ); ?>" data-course-id="<?php echo $course->id; ?>">Enroll now</button>
<?php wp_nonce_field( 'enrollment_process' ); ?>
<input type="hidden" name="course_id" value="<?php echo $course->id; ?>"></form>
<?php
$button = ob_get_clean();
}
}
return $button;
}
Let me know how that goes ??
Cheers,
Bojan