Hey there @mainplus,
How are you doing today?
You can use plugin translation files to replace that word with the word of your choice. You’ll find more info on how to do that here.
This will however change the “details” string on all pages including Courses page. Alternative to that would be using jQuery to replace text whre you can target that button on that page avoiding this to be changed elsewhere, something like this http://stackoverflow.com/questions/5115152/jquery-find-and-replace-string.
Best regards,
Bojan
Hey Bojan
I’m doing good thanks.
I think I may not have explained clearly what I need. I don’t just need to change the text in the button I want to change the action. Instead of taking the student to the course details, I want them to go straight into start learning or continue learning. So basically changing the details button to one that goes into the learning process.
Regards
Dave
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
Hi Bojan
That seems to have done the job. Many thanks, a great bit of coding.
I can’t help but feel there are probably a few other users out there that might like that bit of customisation.
Best Regards
Dave