E-mail Replacing Field_Name Not {Field_Name}

  • Michael Faggard
  • Topic Author
  • Offline
  • New Member
  • New Member
More
14 years 4 months ago #1780 by Michael Faggard
E-mail Replacing Field_Name Not {Field_Name} was created by Michael Faggard
I noticed that the custom replacement fields (the ones surrounded curly braces {}) in the e-mail messages I was receiving were including the curly braces along with the replacement value. Not only that, but everywhere the replacement field word was used (without the curly braces) it was being replaced as well with the replacement value.

I found another thread where there was made mention of the various custom e-mail replacement fields, as follows:

- Campaign title : {campaign}
- First name : {first_name}
- Last name : {last_name}
- Organization : {organization}
- Address : {address}
- city : {city}
- state : {state}
- zip : {zip}
- country : {country}
- phone : {phone}
- email : {email}
- comment : {comment}
- amount : {amount}


As a test site placed the above to be received as my thank you message. After submitting the donation information I received the following from the e-mail:

- Campaign title : {Donation Drive}

- First name : {Michael}

- Last name : {Duderanch}

- Organization : {}

- Address : {123 Main St.}

- Chico : {Chico}

- CA : {CA}

- 96100 : {96100}

- United States : {United States}

- 916-555-5555 : {916-555-5555}

- mikeis2cool@comcast.net : {mikeis2cool@comcast.net}

- test : {test}

- 5.00 : {5.00}


Thank you for any assistance you can provide,

Mike

Please Log in or Create an account to join the conversation.

  • Michael Faggard
  • Topic Author
  • Offline
  • New Member
  • New Member
More
14 years 4 months ago #1781 by Michael Faggard
Replied by Michael Faggard on topic Re:E-mail Replacing Field_Name Not {Field_Name}
Hi again,

I have found the solution by looking at the code. On about line 746 of models/jdonation.php, the following line is used to replace the custom replacement values:

$body = str_replace("{$key}", $value, $body) ;

The problem is with the curly braces surrounding the $key variable: PHP sees the curly braces as part of the string itself with variables. To fix the problem, on mine I did the following:

$body = str_replace("{{$key}}", $value, $body) ;

I believe this problem will occur for people who have newer versions of PHP on their server. I am a little surprised it hasn't come up already, although perhaps it has and I didn't see the post.

I hope this helps if this problem comes up for anyone else.

Cheers!

Mike

Please Log in or Create an account to join the conversation.

More
14 years 4 months ago #1785 by Tuan Pham Ngoc
Replied by Tuan Pham Ngoc on topic Re:E-mail Replacing Field_Name Not {Field_Name}
Hi Mike
Thanks for sharing your solution . I will check it and get back to you soon .
Thanks ,
Ossolution Team

Please Log in or Create an account to join the conversation.

Moderators: Mr. DamDũng Nguyễn Việt