[Resolved] I need multilanguage email. Tutor lms and wpml
This thread is resolved. Here is a description of the problem and solution.
Problem: The client needs multilanguage email support for their site using Tutor LMS and WPML plugins. Tutor LMS doesn't support sending messages in the user's language, and the client attempted to implement a solution using WPML documentation but faced issues. Solution: We are currently aware of the issue with Tutor LMS where email notifications are not being translated into secondary languages. This is a known issue, and we are waiting for the author of Tutor LMS to implement this feature. For more details, please check the known issue here: https://wpml.org/errata/tutor-lms-pro-email-notifications-are-not-being-translated-in-secondary-languages/
If this solution does not apply to your case, or if it seems outdated, we highly recommend checking related known issues at https://wpml.org/known-issues/, verifying the version of the permanent fix, and confirming that you have installed the latest versions of themes and plugins. If you still need assistance, please open a new support ticket at WPML support forum.
This is the technical support forum for WPML - the multilingual WordPress plugin.
Everyone can read, but only WPML clients can post here. WPML team is replying on the forum 6 days per week, 22 hours per day.
Background of the issue:
I need multilanguage email support for my site hidden link using Tutor LMS and WPML plugins. Tutor LMS doesn't support sending messages in the user's language. I tried to make changes myself using the documentation provided by WPML. The code I used is as follows: public function course_enroll_email_to_student( $course_id, $student_id, $enrol_id, $status_to = 'completed' ) { $enroll_notification = tutor_utils()->get_option( 'email_to_students.course_enrolled' ); if ( ! $enroll_notification || 'completed' !== $status_to ) { return; } $student = get_userdata( $student_id ); if ( false === $student ) { return; } $user_language = get_user_meta( $student->ID, 'icl_admin_language', true ); if ( ! $user_language ) { $user_language = 'en'; } do_action('wpml_switch_language_for_email', $user_language); $course = tutor_utils()->get_course_by_enrol_id( $enrol_id ); $enroll_time = tutor_time(); $enroll_time_format = date_i18n( get_option( 'date_format' ), $enroll_time ) . ' ' . date_i18n( get_option( 'time_format' ), $enroll_time ); $course_start_url = tutor_utils()->get_course_first_lesson( $course_id ); $site_url = get_bloginfo( 'url' ); $site_name = get_bloginfo( 'name' ); $option_data = $this->get_option_data( self::TO_STUDENTS, 'course_enrolled' ); $header = 'Content-Type: ' . $this->get_content_type() . "rn"; $header = apply_filters( 'student_course_enrolled_email_header', $header, $enrol_id ); $replacable['{testing_email_notice}'] = ''; $replacable['{user_name}'] = tutor_utils()->get_user_name( $student ); $replacable['{course_name}'] = $course->post_title; $replacable['{enroll_time}'] = $enroll_time_format; $replacable['{course_url}'] = get_the_permalink( $course->ID ); $replacable['{course_start_url}'] = $course_start_url; $replacable['{site_url}'] = $site_url; $replacable['{site_name}'] = $site_name; $replacable['{logo}'] = isset( $option_data['logo'] ) ? $option_data['logo'] : ''; $replacable['{email_heading}'] = $this->get_replaced_text( $option_data['heading'], array_keys( $replacable ), array_values( $replacable ) ); $replacable['{email_message}'] = $this->get_replaced_text( $this->prepare_message( $option_data['message'] ), array_keys( $replacable ), array_values( $replacable ) ); $subject = $this->get_replaced_text( $option_data['subject'], array_keys( $replacable ), array_values( $replacable ) ); ob_start(); $this->tutor_load_email_template( 'to_student_course_enrolled' ); $email_tpl = apply_filters( 'tutor_email_tpl/student_course_enrolled', ob_get_clean() ); $message = html_entity_decode( $this->get_message( $email_tpl, array_keys( $replacable ), array_values( $replacable ) ) ); $this->send( $student->user_email, $subject, $message, $header ); do_action('wpml_restore_language_from_email'); }
Symptoms:
Tutor LMS doesn't support sending messages in the user's language, and the changes I made using WPML documentation didn't help.
Questions:
How can I make Tutor LMS send emails in the user's language using WPML?
What additional steps can I take if the provided WPML documentation doesn't resolve the issue?