CoursePress e-mails WPML compatibility

There's a number of e-mail notifications available in "CoursePress -> Settings -> E-mail Settings". While the rest of CP works fine with WPML these e-mail messages cannot be translated. Is there a way to make it compatible with WPML?

  • Kasia Swiderska

    Hello activemind,

    There are in fact filters that should do the job, however I need to get more info on how can we use them with WPML and if I found the right filter.
    I'm referring to coursepress_default_email_settings filter in includes/coursepress/helper/setting/class-email.php
    I'm checking with one of our Second Line Support developer how this can be done and I will get back to you with more information.

    kind regards,
    Kasia

  • Ivan

    Hi activemind !

    Unfortunately, it's not possible because WPML plugin translates WP Custom Post type and Coursepress saves these settings in options table. But you can use 'coursepress_email_fields-' . $type filter for that, where $type is type of notification (such as registration, enrollment_confirm, instructor_enrollment_notification, course_invitation, course_invitation_password, instructor_invitation, facilitator_invitation, new_order, discussion_notification, course_start, basic_certificate, unit_started, instructor_module_feedback).
    For example, you want to translate User Registration E-mail you can use the following code as MU plugin ( for example, create {wordpress_folder}/wp-content/mu-plugins/wpmu_translate_coursepress_notifications.php file via FTP ).

    <?php
    function wpmu_translate_coursepress_registration_notification( $email, $args ) {
    	$user = get_user_by( 'email', $email['to'] );
    	if ( is_object( $user ) ) {
    		$user_id = $user->ID;
    		$language = '';//here define what language you need use for this user orcontact WPML support for that
    
    		switch ( $language ) {
    			//translates for French
    			case 'fr':
    				$email['subject'] = '';//translate subject to French
    				$email['message'] = '';//translate message to French
    				break;
    			//translates for Spanish
    			case 'es':
    				$email['subject'] = '';//translate subject to Spanish
    				$email['message'] = '';//translate message to Spanish
    				break;
    		}
    	}
    	return $email;
    }
    
    add_filter( 'coursepress_email_fields-registration', 'wpmu_translate_coursepress_registration_notification', 10, 2 );

    Best regards,
    Ivan.

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.