What if I don't have First name/last name but only a custom field called "full name" How to display that field or if thats missing display: "Supporter" instead?

1 Answer 1


You can use Smarty in greetings handling. So first - make sure you're using the "Email Greeting" or "Postal Greeting" token instead of the "First Name" etc. tokens.

Then you can do something like this:

{capture assign=ln}{contact.last_name}{/capture}{if $ln ==""}{contact.custom_1}{else}{contact.last_name}{/if}

See this blog post on greetings handling for more detail.

EDIT: This approach won't work if you need accented characters because of how Smarty works. See https://www.dxsdata.com/2014/05/php-smarty-empties-strings-with-special-characters/ for details.

  • I am quite a beginner I guess, as I read through that page but its still unclear where I should put this smarty code? That post says this: admin/options/postal_greeting but that doesn't exist:-( Is it under admin/communication/email greeting formats? Or should it go at each contacts communication preferences? Or in option groups under system settings? Apr 16, 2020 at 18:48
  • @andras Note that the Smarty I wrote is only an approximation! Translated, it says, "If 'last name' doesn't exist, use the value of the custom field with an ID of '1', otherwise use the last name". Not exactly what you want! To test this, you can click on a single contact's postal greeting and select "Customized". Enter the Smarty there, test until you're happy. Once you're done, the correct place to look is Administer menu » Communications » Postal Greeting Formats (or Email Greeting Formats). Apr 16, 2020 at 22:24
  • What I understand here is that this script chooses between last name and a custom field that in my case would be the full name. But I still don't get what to do when both are missing. Where do I set this to fall back on a word like "Supporter" when I have nothing but an email of a contact. Apr 17, 2020 at 11:16
  • Wow, I almost did it! It works with english characters, Now, the next problem is when I have a special character in the hungarian version of supporter; the letter "ü" and that is causing problems, namely I cannot save the contact if I choose this smarty string. If I get rid of the special character it works nicely, but any non-english character seems prohibited:-( Apr 17, 2020 at 12:54
  • Let me further elaborate here. I can even save the default greeting under email formats, but if it has any non english letters, then if I want to change a contact to use this new type of greeting it cannot be saved, it's giving me error 500 or a message that it cannot connect to the server(?!) Removing the special character allows me so save. I tried using ü instead of "ü" to no avail:-( Apr 19, 2020 at 14:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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