How to add a variable to e-mails (like the one )

Hi there,

 

I had an idea and I'm not being able to put it working simply because I can't find the code.

 

Does anyone know where's the code so I can add a new variable just like <RealName> var?

 

For instance, in the fields I've added a new one so people can write who refered them my website to them and basicaly I want to receive the "New user" e-mail with that refered name that they've inserted.

 

If there's needed any explanation so you can understand it better, just make your question and obviously that I will be glad to answer as this is for my interrest. :)

 

Thanks a lot.

 

Best regards,

Pedro

Quote · 5 Jan 2011

 

Hi there,

 

I had an idea and I'm not being able to put it working simply because I can't find the code.

 

Does anyone know where's the code so I can add a new variable just like <RealName> var?

 

For instance, in the fields I've added a new one so people can write who refered them my website to them and basicaly I want to receive the "New user" e-mail with that refered name that they've inserted.

 

If there's needed any explanation so you can understand it better, just make your question and obviously that I will be glad to answer as this is for my interrest. :)

 

Thanks a lot.

 

Best regards,

Pedro

Hello open the : inc/utils.inc.php

 

find these code string :

if ($aPlus || $iRecipientID) {
if(!is_array($aPlus))
$aPlus = array();

 

and add this code line after that :

$aPlus['RealName'] = $aRecipientInfo['FirstName'] . ' ' . $aRecipientInfo['LastName'];

PS: If possible do not write me personally, please try to ask on the forum first
Quote · 5 Jan 2011

Hi SashaE,

First of all, thanks a lot for your help. Unfortunately, it didn't worked out.

What I want is not the e-mail to show the real name, I've just gave the example of the original VAR that comes with the original code.

What I want is the e-mail to show the content of a new field that I've created. That new field, people write on it the name of the user that recommended them.

So I've changed this like code that I found on ..inc/utils.inc.php:

if ($aPlus || $iRecipientID) {
     if(!is_array($aPlus))
            $aPlus = array();
     $oEmailTemplates = new BxDolEmailTemplates();
     $sMailSubject = $oEmailTemplates->parseContent($sMailSubject, $aPlus, $iRecipientID);
     $sMailBody = $oEmailTemplates->parseContent($sMailBody, $aPlus, $iRecipientID);
    }

To this, based on what you suggested:

if ($aPlus || $iRecipientID) {
     if(!is_array($aPlus))
            $aPlus = array();
     $oEmailTemplates = new BxDolEmailTemplates();
     $sMailSubject = $oEmailTemplates->parseContent($sMailSubject, $aPlus, $iRecipientID);
     $sMailBody = $oEmailTemplates->parseContent($sMailBody, $aPlus, $iRecipientID);
     $aPlus['Refer'] = $aRecipientInfo['Recomend'];
    }

The name of the field is Recomend and I was using on the e-mail templates, the var <Refer> (just as there are <email>, <RealName> and <recipientID>).

Is there anything I'm doing wrong?

Thanks a lot.

Best regards,
Pedro

Quote · 5 Jan 2011

Btw, here's the original e-mail template code:

<html><head></head><body style="font: 12px Verdana; color:#000000">
<p>New user <RealName> with email <Email> has joined, his/her ID is <recipientID></p>

<p>--</p>
<p style="font: bold 10px Verdana; color:red"><SiteName> mail delivery system!!!
<br />Auto-generated e-mail, please, do not reply!!!</p></body></html>

Basically I want to have something like this:

<html><head></head><body style="font: 12px Verdana; color:#000000">
<p>New user <RealName> with email <Email> has joined, his/her ID is <recipientID> and it was recomended by user <Refer></p>

<p>--</p>
<p style="font: bold 10px Verdana; color:red"><SiteName> mail delivery system!!!
<br />Auto-generated e-mail, please, do not reply!!!</p></body></html>

It's probably more explicit now. :)

Quote · 5 Jan 2011

 

Hi SashaE,

First of all, thanks a lot for your help. Unfortunately, it didn't worked out.

What I want is not the e-mail to show the real name, I've just gave the example of the original VAR that comes with the original code.

What I want is the e-mail to show the content of a new field that I've created. That new field, people write on it the name of the user that recommended them.

So I've changed this like code that I found on ..inc/utils.inc.php:

if ($aPlus || $iRecipientID) {
if(!is_array($aPlus))
$aPlus = array();
$oEmailTemplates = new BxDolEmailTemplates();
$sMailSubject = $oEmailTemplates->parseContent($sMailSubject, $aPlus, $iRecipientID);
$sMailBody = $oEmailTemplates->parseContent($sMailBody, $aPlus, $iRecipientID);
}

To this, based on what you suggested:

if ($aPlus || $iRecipientID) {
if(!is_array($aPlus))
$aPlus = array();
$oEmailTemplates = new BxDolEmailTemplates();
$sMailSubject = $oEmailTemplates->parseContent($sMailSubject, $aPlus, $iRecipientID);
$sMailBody = $oEmailTemplates->parseContent($sMailBody, $aPlus, $iRecipientID);
$aPlus['Refer'] = $aRecipientInfo['Recomend'];
}

The name of the field is Recomend and I was using on the e-mail templates, the var <Refer> (just as there are <email>, <RealName> and <recipientID>).

Is there anything I'm doing wrong?

Thanks a lot.

Best regards,
Pedro

Please read my post carefully I wrote that you add this code :  $aPlus['Refer'] = $aRecipientInfo['Recomend'];

after :

if ($aPlus || $iRecipientID) {
if(!is_array($aPlus))
$aPlus = array();

 

and before :

$oEmailTemplates = new BxDolEmailTemplates();

PS: If possible do not write me personally, please try to ask on the forum first
Quote · 5 Jan 2011

Yeah! It just worked great! :D

 

Thanks a lot SashaE, you're a great helper indeed.

 

Have a graet 2011! ;)

Quote · 5 Jan 2011

Well, I actually have another doubt now! :P

 

How can I add a new var?

 

The new one I want to add it's a Voucher field, and I've added the code line bellow and it's not showing. :(

Quote · 5 Jan 2011

SashaE, where are you? :P

Quote · 5 Jan 2011

Some simple help here please. Certainly SashaE know the answer. :)

Quote · 5 Jan 2011

SashaE, where are you?

 

Can anyone help me here?

Quote · 6 Jan 2011

 

SashaE, where are you?

 

Can anyone help me here?

You can add other variables as well as done before:

 

$aPlus['Refer'] = $aRecipientInfo['Recomend'];

$aPlus['RealName'] = $aRecipientInfo['FirstName'] . ' ' . $aRecipientInfo['LastName'];

$aPlus['RealName'] = $aRecipientInfo['FirstName'] . ' ' . $aRecipientInfo['LastName'];

.........................

PS: If possible do not write me personally, please try to ask on the forum first
Quote · 7 Jan 2011

I did that, it was my first though.

 

But it doesn't work! :(

Quote · 8 Jan 2011

People, I really need your help.

 

The problem is, only the first var is appearing (the first I've inserted with for the "Recomend"), the others are not appearing in the automatic e-mail.

 

Can anyone, please, give me a hint on this one?

Quote · 29 Jan 2011

The procedure provided is correct.

$aPlus['Refer'] = $aRecipientInfo['Recomend'];

$aPlus['New1'] = $aRecipientInfo['Newfield1'];

$aPlus['New2'] = $aRecipientInfo['Newfield2'];

So you need to check some other things. The new field your trying to insert has to be a profile field, and if it's empty it also will not appear.

https://www.deanbassett.com
Quote · 29 Jan 2011

 

The procedure provided is correct.

$aPlus['Refer'] = $aRecipientInfo['Recomend'];

$aPlus['New1'] = $aRecipientInfo['Newfield1'];

$aPlus['New2'] = $aRecipientInfo['Newfield2'];

So you need to check some other things. The new field your trying to insert has to be a profile field, and if it's empty it also will not appear.

 

 

It's really weird because I've done that and it didn't worked...

 

I decided to give it a shot and try to change the code myself, but it didn't worked either. :(

 

This is what I've tried:

 

On line 409 I've changed this original line:

function sendMail( $sRecipientEmail, $sMailSubject, $sMailBody, $iRecipientID = 0, $aPlus = array(), $sEmailFlag = 'html' ) {

To this:

function sendMail( $sRecipientEmail, $sMailSubject, $sMailBody, $iRecipientID = 0, $aPlus = array(), $aPlus1 = array(), $aPlus2 = array(), $sEmailFlag = 'html' ) {

 

And then I've changed the IF on line 420 from this:

    if ($aPlus || $iRecipientID) {
     if(!is_array($aPlus))
            $aPlus = array();
     $aPlus['Refer'] = $aRecipientInfo['Recomend'];
     $oEmailTemplates = new BxDolEmailTemplates();
     $sMailSubject = $oEmailTemplates->parseContent($sMailSubject, $aPlus, $iRecipientID);
     $sMailBody = $oEmailTemplates->parseContent($sMailBody, $aPlus, $iRecipientID);
    }

To this:

    if ($aPlus && $aPlus1 && $aPlus2 || $iRecipientID) {
     if(!is_array($aPlus) && !is_array($aPlus1) && !is_array($aPlus2))
            $aPlus = array();
   $aPlus1 = array();
   $aPlus2 = array();
   $aPlus['Refer'] = $aRecipientInfo['Recomend'];
   $sPlus1['Codigo'] = $aRecipientInfo['Voucher'];
   $sPlus2['Pais'] = $aRecipientInfo['Country'];
     $oEmailTemplates = new BxDolEmailTemplates();
     $sMailSubject = $oEmailTemplates->parseContent($sMailSubject, $aPlus, $aPlus1, $aPlus2, $iRecipientID);
     $sMailBody = $oEmailTemplates->parseContent($sMailBody, $aPlus, $aPlus1, $aPlus2, $iRecipientID);
    }

But still, isn't working! :(

 

And yes, each time I've tested the things I've cleaned the cache before.

Quote · 29 Jan 2011

No.

Whats this $sPlus1 and  $sPlus2 your adding.

$sPlus is an array. All your values are to be pushed to the same array name. Your creating additionals which is not how it should be.

More like this.

function sendMail( $sRecipientEmail, $sMailSubject, $sMailBody, $iRecipientID = 0, $aPlus = array(), $sEmailFlag = 'html' ) {

if ($aPlus || $iRecipientID) {
if(!is_array($aPlus))
$aPlus = array();
$aPlus['Refer'] = $aRecipientInfo['Recomend'];
$sPlus['Codigo'] = $aRecipientInfo['Voucher'];
$sPlus['Pais'] = $aRecipientInfo['Country'];

$oEmailTemplates = new BxDolEmailTemplates();
$sMailSubject = $oEmailTemplates->parseContent($sMailSubject, $aPlus, $iRecipientID);
$sMailBody = $oEmailTemplates->parseContent($sMailBody, $aPlus, $iRecipientID);
}

So this is the origional with just these 2 added.

$sPlus['Codigo'] = $aRecipientInfo['Voucher'];
$sPlus['Pais'] = $aRecipientInfo['Country'];

Notice the $sPlus is the same for each that you add. This adds a new item to the same array.

https://www.deanbassett.com
Quote · 29 Jan 2011

As said, that's how it was and that's how I changed in the first place, but it simply doesn't work! :(

 

What can it be?

Quote · 29 Jan 2011

Hold on, i have to rewrite that.

I just noticed i copied your names which also will not work. I have to dig up the origional code. and work with that.

https://www.deanbassett.com
Quote · 29 Jan 2011

 

Hold on, i have to rewrite that.

I just noticed i copied your names which also will not work. I have to dig up the origional code. and work with that.

 

Awesome! :)

 

Thanks a lot. The file is in ..inc/utils.inc.php

 

Waiting for your reply. ;)

Quote · 29 Jan 2011

Ok. Here is the origional code.

if ($aPlus || $iRecipientID) {
if(!is_array($aPlus))
$aPlus = array();

$oEmailTemplates = new BxDolEmailTemplates();
$sMailSubject = $oEmailTemplates->parseContent($sMailSubject, $aPlus, $iRecipientID);
$sMailBody = $oEmailTemplates->parseContent($sMailBody, $aPlus, $iRecipientID);
}


Now just add the 3 lines as shown below.

if ($aPlus || $iRecipientID) {
if(!is_array($aPlus))
$aPlus = array();
$aPlus['Refer'] = $aRecipientInfo['Recomend'];
$aPlus['Codigo'] = $aRecipientInfo['Voucher'];
$aPlus['Pais'] = $aRecipientInfo['Country'];

$oEmailTemplates = new BxDolEmailTemplates();
$sMailSubject = $oEmailTemplates->parseContent($sMailSubject, $aPlus, $iRecipientID);
$sMailBody = $oEmailTemplates->parseContent($sMailBody, $aPlus, $iRecipientID);
}

As long as the profile fields Recomend, Voucher and Country are not empty it should work. Now i would assume all three of those are required fields on your join form preventing them from being blank.

https://www.deanbassett.com
Quote · 29 Jan 2011

No, they're not required fields (except the Country which is the standard countries list in a selectbox). So that one will always contain something.

 

Regarding the code, you did the same thing, the code is the same and as I said, I've already used that code and the only working was "Refer".

 

How do I know that is not working? Simple, I test it by registering myself a new user...

 

This is really weird... :(

Quote · 29 Jan 2011

Than i can't explain it.

But you can't do it the way you tried. The templates were not designed for all those extra values you were trying to pass to the template parse function and the sendmail function it's self is called from many locations in dolphin so you can't simply add more parameters to its function definition.

The way both me a sasha told you to do it is the proper way, so i cannot explain why they are not showing up.

So double check your templates, and clear your cache. Manually to make sure it gets cleared.

https://www.deanbassett.com
Quote · 29 Jan 2011

I can not fu***ng understand this s**t...

 

Can you believe that I replaced my old code (which is equal to yours) and this time it just worked?!?!

 

Oh my...

 

Anyway, thanks a million for your kind help. :)

 

And also thanks to Sasha. ;)

Quote · 29 Jan 2011

Your welcome.

https://www.deanbassett.com
Quote · 29 Jan 2011

On a related note, where can one find all the parameters appearing in email templates, like the following:

<RealName>
<Domain>
<recipientID>
<Password>
<Email>
<MessageSubject>
<Domain>
<MessageText>
<ProfileUrl>
<ProfileReference>
<ConfCode>
<ConfirmationLink>

Can a parameter appearing in one email template be used in another template if it's not already used (like a global variable)?

Thanks!

Quote · 27 Feb 2011
 
 
Below is the legacy version of the Boonex site, maintained for Dolphin.Pro 7.x support.
The new Dolphin solution is powered by UNA Community Management System.