1

CiviCRM for WordPress 4.7.15

Problem: Fix the Email Greeting, so it takes advantage of the preferred language and gender fields. I took a look at:

https://wiki.civicrm.org/confluence/display/CRMDOC/Recipe+for+German+Name+and+Greetings+Handling

The page to edit the Email Greeting is hidden under Administration/System Settings/Option Groups - Email Type Greeting Options

I came up with the following which works nicely when used in a Smarty Message Template.

{capture assign=l}{contact.preferred_language}{/capture} 
{capture assign=g}{contact.gender}{/capture} 
{if $l="en_CA"}Dear{else}{if $g="Male"}Cher{else}Chère{/if}{/if} {contact.first_name} {contact.last_name}

To test it, one selects the new Email Greeting from the drop down on the Contacts Summary page in the Communication Preferences section. Then clicks Save. At this point, the CiviCRM says.

Error Message

Any suggestions? I'm considering adding 3 Greetings and updating all 2697 records via SQL.

1

I am a bit of a hurry at the moment - we use a greeting based on the prefix - maybe it helps:

{capture assign=c}{contact.communication_style}{/capture}{capture assign=p}{contact.individual_prefix}{/capture}{if $p=="Frau"}Liebe{else}Lieber{/if}{ }{if $c=="Familiar"}{ }{contact.first_name}{else}{$p}{ }{contact.formal_title}{contact.last_name}{/if}

  • Are you on 4.7.15? Because in my case, using the greeting with capture commands "crashes" CiviCRM page. Crashes as in it never finishes reloading the page. In the message context the variables are defined. Maybe they are not in the greeting context. Worth a try. – Codedogs Feb 8 '17 at 18:11
  • I tried just contract.preferred_language and just contact.gender and both resulted in a Network Error. – Codedogs Feb 9 '17 at 2:45
  • I just ried it on the sandbox which is on 4.7.17 - seems to work – Fabian Feb 9 '17 at 7:16
  • I gave up and did it via SQL – Codedogs Feb 2 '18 at 18:48
1

Meanwhile, we have developed a new extension which may help people struggling with many different and or/complex greetings. The extension (including documentation) can be found here.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.