Correctly adding and using the tag '{EMAIL}' Correctly adding and using the tag '{EMAIL}'
 

News:

CPG Release 1.6.26
Correct PHP8.2 issues with user and language managers.
Additional fixes for PHP 8.2
Correct PHP8 error with SMF 2.0 bridge.
Correct IPTC supplimental category parsing.
Download and info HERE

Main Menu

Correctly adding and using the tag '{EMAIL}'

Started by TeacherMac, December 30, 2012, 09:18:03 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

TeacherMac

I added the tag '{EMAIL}' to register.php

$template_vars = array(
            '{SITE_NAME}' => $CONFIG['gallery_name'],
            '{USER_NAME}' => $user_name,
            '{ACT_LINK}'  => $act_link,
       '{EMAIL}'  => $email,

Which works fine when called in the new user's Registration confirmation email:

But does not work when used with the Registration request email received by the administrator.

$lang_register_approve_email = <<< EOT
A new user with the username "{USER_NAME}" and the email address "{EMAIL}" has registered in your gallery.
In order to activate the account, you need to click on the link below or copy and paste it in your web browser.

<a href="{ACT_LINK}">{ACT_LINK}</a>

EOT;

And doesn't work with the Activation notification email received by the new user:

$lang_register_php['activated_email'] = <<< EOT

Your account has been approved and activated.

You can now log in at <a href="{SITE_LINK}">{SITE_LINK}</a> using the email address you used to register "{EMAIL}"


Regards,

The management of {SITE_NAME}

EOT;

I just can't seem to find the answer so help would be appreciated.

TeacherMac

I added the tag '{EMAIL}' to register.php

$template_vars = array(
            '{SITE_NAME}' => $CONFIG['gallery_name'],
            '{USER_NAME}' => $user_name,
            '{ACT_LINK}'  => $act_link,
       '{EMAIL}'  => $email,

Which works fine when called in the new user's Registration confirmation email:

But does not work when used with the Registration request email received by the administrator.

$lang_register_approve_email = <<< EOT
A new user with the username "{USER_NAME}" and the email address "{EMAIL}" has registered in your gallery.
In order to activate the account, you need to click on the link below or copy and paste it in your web browser.

<a href="{ACT_LINK}">{ACT_LINK}</a>

EOT;

And doesn't work with the Activation notification email received by the new user:

$lang_register_php['activated_email'] = <<< EOT

Your account has been approved and activated.

You can now log in at <a href="{SITE_LINK}">{SITE_LINK}</a> using the email address you used to register "{EMAIL}"


Regards,

The management of {SITE_NAME}

EOT;

I just can't seem to find the answer so help would be appreciated.

TeacherMac

Appears I posted this in the wrong forum.

I have posted it to the correct forum so please disregard the posting here.

Thanks,

Mac

TeacherMac

Seems someone, trying to be helpful, may have inadvertently given the impression that this request for support was answered.

Probably because I originally posted in the wrong forum and tried to resolve that myself.

In short, I would appreciate help in resolving my problem.

Thanks and best wishes to all for the New Year,

Mac

Αndré

Please check if you have added
'{EMAIL}'  => $email,
to all occurrences of
            $template_vars = array(
                '{SITE_NAME}' => $CONFIG['gallery_name'],
                '{USER_NAME}' => $row['user_name'],
                '{ACT_LINK}' => $act_link,
            );

(there are 4 in register.php).

TeacherMac

Hi Andrea and all the best for the New Year!

Yes there are 4 areas that can be changed and here are the results I've documented

Adding '{EMAIL}' to line 624 of the first "$template_vars = array" (located on line 620)

Admin Registration notification email: USER_Name & EMAIL variables display correctly
User Registration confirmation email:  USER_Name & EMAIL variables display correctly
Admin Registration request email: USER_Name displayed correctly but EMAIL variables displayed as "EMAIL"
User Activation notification email:  USER_Name displayed correctly but EMAIL variables displayed as "EMAIL"

Adding '{EMAIL}' to line 675 of the second "$template_vars = array" (located on line 671)

Admin Registration notification email: USER_Name & EMAIL variables display correctly
User Registration confirmation email:  USER_Name & EMAIL variables display correctly
Admin Registration request email: USER_Name displayed correctly but EMAIL variables displayed as "EMAIL"
User Activation notification email:  USER_Name displayed correctly but EMAIL variables displayed as "EMAIL"

Adding '{EMAIL}' to line 764 of the second "$template_vars = array" (located on line 760)

Admin Registration notification email: USER_Name & EMAIL variables display correctly
User Registration confirmation email:  USER_Name & EMAIL variables display correctly
Admin Registration request email: USER_Name displayed correctly but EMAIL variables displayed as "EMAIL"
User Activation notification email:  USER_Name displayed correctly but EMAIL variables displayed as "" (Empty Quotes)

Adding '{EMAIL}' to line 799 of the second "$template_vars = array" (located on line 803)

Admin Registration notification email: USER_Name & EMAIL variables display correctly
User Registration confirmation email:  USER_Name & EMAIL variables display correctly
Admin Registration request email: USER_Name displayed correctly but EMAIL variables displayed as "" (Empty Quotes)
User Activation notification email:  USER_Name displayed correctly but EMAIL variables displayed as "" (Empty Quotes)

I appreciate your time in looking into this matter.

Mac

Αndré

If there are empty quotes the token has been replaced successfully, but unfortunately $email is empty/doesn't exist at that point. Maybe the email address exists in another variable/array, if not, you have to get it from the SQL database.

TeacherMac

I do appreciate your pointing out the obvious as I did take the time to try to find an answer.

I finally asked for support here and was actually hoping for some help with the coding, specifically in how to retrieve the information from the database and apply it where I needed it.

I hope someone else might be able to help.

Have a good year.

Thanks for our help,

Mac

Αndré

If your gallery is unbridged, something like
$email = mysql_result(cpg_db_query("SELECT user_email FROM {$CONFIG['TABLE_USERS']} WHERE user_name = '{$row['user_name']}' LIMIT 1"), 0);
should populate the $email variable. As I haven't tested the code it may contain typos. Please add it above $template_vars = array( and report if it works as expected.

TeacherMac

Thank you André! :D

That's the help I needed and the code worked fine ( no typos I guess lol)

To help others who may appreciate this, I inserted the code you provided: "$email = mysql_result(cpg_db_query("SELECT user_email FROM {$CONFIG['TABLE_USERS']} WHERE user_name = '{$row['user_name']}' LIMIT 1"), 0);"

before "$template_vars = array( " in the file register.php which is located in the root directory which only had to be done in two locations as shown below.

The code inserted on (my line 759) enabled the variable "EMAIL" to be displayed correctly in the user's "Activation notification" email.

(755) //after admin approves, user receives email notification
(756)    if ($user_status == 'active_admin') {
(757)   
(758)        msg_box($lang_register_php['information'], $lang_register_php['acct_active_admin_activation'], $lang_common['continue'], 'index.php');
(759)$email = mysql_result(cpg_db_query("SELECT user_email FROM {$CONFIG['TABLE_USERS']} WHERE user_name = '{$row['user_name']}' LIMIT 1"), 0);
(760)       $template_vars = array(
(761)            '{SITE_LINK}' => $CONFIG['site_url'],
(762)            '{USER_NAME}' => $row['user_name'],
(763)            '{SITE_NAME}' => $CONFIG['gallery_name'],
(764)             '{EMAIL}'  => $email,
(765)
(766)        );
      
The code inserted on (my line 799) enabled the variable "EMAIL" to be displayed correctly in the administrator's "Registration request" email.
      
(798)            $act_link = rtrim($CONFIG['site_url'], '/') . '/register.php?activate=' . $act_key;
(799)$email = mysql_result(cpg_db_query("SELECT user_email FROM {$CONFIG['TABLE_USERS']} WHERE user_name = '{$row['user_name']}' LIMIT 1"), 0);
(800)            $template_vars = array(
(801)                '{SITE_NAME}' => $CONFIG['gallery_name'],
(802)                '{USER_NAME}' => $row['user_name'],
(803)                '{ACT_LINK}' => $act_link,
(804)                '{EMAIL}'  => $email
(805)            );

Thanks again for your assistance and please mark this as SOLVED!

Mac

phill104

Marking as solved is only omething you can do as the thread starte ;)

Thanks for showing us your completed work, it always comes in handy helping others.
It is a mistake to think you can solve any major problems just with potatoes.