Home › Forums › Front End PM PRO › Problem with sending emails
Tagged: announcements, mails, messages
- This topic has 7 replies, 2 voices, and was last updated 6 years, 3 months ago by Shamim Hasan.
-
AuthorPosts
-
August 3, 2018 at 3:36 am #16139test programmerParticipant
I have problems sending emails with messages & announcements. The setting from the user to receive an email with a message or announcement is active.
This works for messages. Only not in the language set by the user. In the templates folder (/front-end-pm-pro/templates/emails) I have the following files:
- new_announcement_en.php
- new_announcement_fr.php
- new_announcement_nl.php
- new_answer_en.php
- new_answer_fr.php
- new_answer_nl.php
- new_message_en.php
- new_message_fr.php
- new_message_nl.php
Is there a possibility to make this dependent on the language of the user?
In the case of announcements, no mails are sent at all. While this is active set in backend.
What could be the reason for this?
August 3, 2018 at 9:35 am #16144Shamim HasanKeymasterPlease follow https://www.shamimsplugins.com/docs/front-end-pm-pro/customization-front-end-pm-pro/create-own-email-template/
Within your template conditionally include your user set language template.
August 3, 2018 at 7:37 pm #16160test programmerParticipantI now have the following:
add_filter( 'fep_eb_email_legends', 'fep_cus_fep_email_legends', 10, 3); function fep_cus_fep_email_legends( $legends, $post, $user_email ){ $user = get_user_by( 'email', $user_email ); $language = get_user_meta( (int)$user->ID, 'icl_admin_language', true ); $legends['receiver_language'] = array( 'description' => __('Receiver language', 'front-end-pm'), 'where' => array( 'newmessage', 'reply', 'announcement' ), //where this tag will be used 'replace_with' => $language ); return $legends; } add_filter( 'fep_eb_templates', 'fep_cus_fep_eb_templates', 10, 2 ); function fep_cus_fep_eb_templates( $templates, $where ) { $templates['new_message'] = 'Nieuw bericht'; return $templates; }
In my template I have the language by the added field receiver_language.
But how can I use this in my template in an if structure?
Is this the way I should do this?
August 3, 2018 at 8:30 pm #16165Shamim HasanKeymasterNo need to create legend for that.
Proceed in following way.
1. register your email template
add_filter( 'fep_eb_templates', function( $templates, $where ) { $templates['new_message'] = 'Nieuw bericht'; return $templates; }, 10, 2 );
2. Now in
emails/new_message.php
file use$language = get_user_meta( fep_get_userdata( $user_email, 'ID', 'email'), 'icl_admin_language', true ); if( 'fr' == $language ){ require( fep_locate_template( 'emails/new_message_fr.php' ) ); }
Let me know.
August 3, 2018 at 9:08 pm #16169test programmerParticipantThank you! Works perfect! Do you also know how I can change the subject of the mail? So it’s translated?
August 4, 2018 at 12:12 am #16183Shamim HasanKeymasterPlease use
fep_filter_before_email_send
filterAugust 5, 2018 at 11:36 pm #16240test programmerParticipantI’ve tried this:
add_filter( 'fep_filter_before_email_send', 'change_email_subject', 10, 3 ); function change_email_subject($content, $post, $user_email) { $current_language = apply_filters( 'wpml_current_language', NULL ); $language = get_user_meta( fep_get_userdata( $user_email, 'ID', 'email'), 'icl_admin_language', true ); // set language of user do_action( 'wpml_switch_language', $language ); $subject = ""; if($post->post_type == "fep_message") { $subject = sprintf( __('ZOUTE GRAND PRIX®: New message', 'zoute_theme' )); } $content['subject'] = $subject; do_action( 'wpml_switch_language', $current_language ); return $content; }
When I try to dump the $content before returning it, the subject is changed correctly. The content of the message itself not (but is changed afterwards with template in /emails folder).
But when I receive the email, the subject is not changed. It’s overwritten by the subject configured in backoffice.
Why doesn’t it work?
August 6, 2018 at 12:08 am #16242Shamim HasanKeymasterinstead of 10 use higher priority.
-
AuthorPosts
You need to purchase ‘Front End PM PRO’ to create topic in this support forum.
If you already purchased ‘Front End PM PRO’ please LOGIN.