Advanced search  

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

Pages: [1]   Go Down

Author Topic: New user admin notification email details  (Read 10284 times)

0 Members and 1 Guest are viewing this topic.

Graham66

  • Coppermine newbie
  • Offline Offline
  • Posts: 10
New user admin notification email details
« on: April 20, 2009, 06:01:07 pm »

This has been covered before, but I am having no success whatever in adding additional information to the admin notification email sent when a new user registers.  In addition to the user name, I want the email to contain all the information the user has entered, taken from $profile1 - 6.

I have tried the method suggested by Sami in reply #15 in the thread at http://forum.coppermine-gallery.net/index.php/topic,37086.0.html.  The only difference is that I an using english_gb.php (and I have checked this is the language selected in the configutation menu).

I have also tried the code published by UrOnline at http://forum.coppermine-gallery.net/index.php/topic,39006.msg184822.html#msg184822.

Both should work, but neither does.

The same email body text appears in 'notify_admin_email_body' and $lang_register_approve_email - but however much I change the text in them, exactly the same text appears in the email notification, with is "A new user with the username "[whatever this is]" has registered in your gallery."  There is then a new paragraph which begins "In order to activate the account...".  None of the extra information appears.  Yet I have no difficulty adding the information into the CPG_ACCESS_LOG.

What I am failing to understand is where the text is being picked up from, when I have altered 'notify_admin_email_body' and $lang_register_approve_email.  Could it somehow be picking it up from english.php, even though the default language is english_gb.php?  If so, how do I persuade it to look only at the english_gb.php version?

This should be so simple, even for a newbie such as I.  If anyone can give any guidance as to what I am failing to do or doing wrong, it would be much appreciated.  Apologies if this has been covered elsewhere other than in the threads I hav equoted above, but if it has, I have not been able to find it.

My site is www.a1rat.com/coppermine, version is 1.4.21.

Thanks in anticipation.

Graham
Logged

Joe Carver

  • Dev Team member
  • Coppermine addict
  • ****
  • Country: us
  • Offline Offline
  • Gender: Male
  • Posts: 1545
  • aka 'i-imagine'
    • Home Page
Re: New user admin notification email details
« Reply #1 on: April 20, 2009, 09:50:21 pm »

Your question was something on my "to do" list (wanting at least the new user's email). Here is what I did to get the email info. into the admin. notification. (based on the thread you referenced).
Mods done on files register.php and english.php in version Coppermine Photo Gallery 1.4.21. The mod. returns only the email address, which I hope is a start for you.
Quote
In file english.php find (in your case file english_gb.php (or try either, to test))
Code: [Select]
'notify_admin_email_body' => 'A new user with the username "%s" has registered in your gallery',
Quote
replace with
Code: [Select]
'notify_admin_email_body' => 'A new user with the username: "%s", email: "%s" has registered in your gallery',
Quote
in file register.php find
Code: [Select]
$template_vars = array(
                                                        '{SITE_NAME}' => $CONFIG['gallery_name'],
                                                        '{USER_NAME}' => $user_name,
                                                        '{ACT_LINK}' => $act_link
Quote
replace with
Code: [Select]
$template_vars = array(
                                                       '{SITE_NAME}' => $CONFIG['gallery_name'],
                                                                        '{USER_NAME}' => $user_name,
                                                                        '{ACT_LINK}' => $act_link,
'{EMAIL}' => $email,

Quote
in file register.php find
Code: [Select]
sprintf($lang_register_php_def['notify_admin_email_body'], $user_name));
Quote
replace with
Code: [Select]
sprintf($lang_register_php_def['notify_admin_email_body'], $user_name, $email));
You should be able to add more variables, but be cautious. It seemed to return no user information (blank) as the notification email's subject if an undefined variable was in the language mod. Maybe you can add one field at a time. Since I'm happy with just the email info. I plan to to pursue it no further. However it would be interesting to know how you make out with all of the information you are looking to get.
Good Luck! 
« Last Edit: April 20, 2009, 10:03:07 pm by i-imagine »
Logged

Graham66

  • Coppermine newbie
  • Offline Offline
  • Posts: 10
Re: New user admin notification email details
« Reply #2 on: April 20, 2009, 10:51:16 pm »

Thank you.  I am at home now and have been testing this (I was at work before doing this in my lunchbreak!).  The email advising me of your reply to this thread arrived at exactly the same time as my first successful email on a dummy new user registration! 

I made the amendments to english.php, not english_gb.php, and it worked exactly as expected.  In fact, rather than making the amendments you suggested, I made the changes to $lang_register_approve_email.  I had previously tried to change 'notify_admin_email_body' in english.php more or less as you suggested, but this did not work.  Since this works for me, this is how I am going to leave it, for the time being at least.  Also this approach gives me more, simple, formatting contol over the email - in this way, I can copy the block with the real name and address to fulfill a postal order, for example - you can just put in whatever fields you want, where you want. 

You will see that, in addition to the information submitted by the user, I have also made the email record the IP address from which the new user logged in.  I know that IP addresses often change, but it may conceivably be of help if you can at least see the IP address when deciding whether or not to approve a new user.

To be specific about what I did, I amended from line 314 onwards in register.php to read:

Code: [Select]
if ($CONFIG['admin_activation']==1) {
                                                        $act_link = rtrim($CONFIG['site_url'], '/') . '/register.php?activate=' . $act_key;
                                                        $template_vars = array(
                                                                        '{SITE_NAME}' => $CONFIG['gallery_name'],
                                                                        '{USER_NAME}' => $user_name,
                                                                        '{ACT_LINK}' => $act_link,
'{USER_MAIL}' => $email,
'{PROFILE1}' => $profile1,
'{PROFILE2}' => $profile2,
'{PROFILE3}' => $profile3,
'{PROFILE4}' => $profile4,
'{PROFILE5}' => $profile5,
'{PROFILE6}' => $profile6,
'{PASSWORD}' => $password,
                                                        );

Then I amended from line 1559 of english.php to read:

Code: [Select]
$lang_register_approve_email = <<<EOT
A new user with the username "{USER_NAME}" has registered in your gallery.

Their email address is "{USER_MAIL}" and password "{PASSWORD}"

Their IP address was: {$_SERVER['REMOTE_ADDR']}

Their full details are:

{PROFILE1}
{PROFILE2}
{PROFILE3}
{PROFILE4}
{PROFILE5}

They also gave the following additional information:

"{PROFILE6}"

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;

Quite why this works amending english.php, when my default language is english_gb.php, I don't know.  I wonder if this is a bug in whatever routine selects the default language, which does not cater for the fact that there is American English and proper English?

Thank you very much for your response.

Graham
Logged

Joe Carver

  • Dev Team member
  • Coppermine addict
  • ****
  • Country: us
  • Offline Offline
  • Gender: Male
  • Posts: 1545
  • aka 'i-imagine'
    • Home Page
Re: New user admin notification email details
« Reply #3 on: April 20, 2009, 11:33:54 pm »

I'm glad to hear you had success. Perhaps this thread now should be marked as solved and, if I may be so bold to suggest, that a mod. post could be made of this thread. Others might find it useful too.
Now I have to implement it on another installation...)
Cheers
i-imagine      i-imagine.net         gallery.josephcarver.com/natural/


p.s. careful with the b word....Coppermine is pretty complex from this newbies perspective and works quite well  "out of the box"

Graham66

  • Coppermine newbie
  • Offline Offline
  • Posts: 10
Re: New user admin notification email details
« Reply #4 on: April 21, 2009, 10:44:38 pm »

In my post yesterday I wondered whether there might be a bug in the language selection routines somewhere.  I have now been testing this a little more.

I am in the UK.  My default language, detected in the config section, is english_gb.  But my problem prior to my previous email was that email new user notification template changes made in the english_gb.php lang file were not being picked up - despite this being my chosen language and the default language recognised in the config section, it was only when I made changes to the english.php file that the changes showed up in new registration emails.

As an experiment, I duplicated the english_gb.php file and renamed the duplicate british.php (and changed the headers so that it was recognised as British in the language seletion options in the config panel).  I made small changes to the new user email notification template in each of the three Englsih language files (english.php, english_gb.php and british.php), so that I could see from the email which language file had been used to create the template.

This is what happened.  If I selected English as my language, the email was generated using the english.php template (as you would expect).  If I selected British as my language, the email was generated using the british.php template (as you would expect).  But if I selected English GB as my language, the english_gb template was never picked up, at all. 

What seemed to happen was that selecting English_GB as my language did nothing at all - it left the previously selected language in place.  I tried French and Estonian as well - the email templates duly changed language.  But the only way to get back to an English version was to select English (not English_GB).  Maybe this accounts for the fact that, not once, in an hour or more of trying, did I manage to get the user notification email generated by the language file selected in the config panel, namely english_gb.  I tried everything I could think of, including clearing the browser cache and running ccleaner between new instances of my gallery to clear temporary files and cookies, but nothing made any difference.

I looked in the database log.  Every time I changed to a language other than english_gb, there was an entry along the lines of "CONFIG UPDATE SQL: UPDATE cpg14x_config SET value = 'french' WHERE name = 'lang' TIME: April 21, 2009, 2:54 pm".  But there were no database entries showing a change to english_gb, however many times I tried to save the configuration with this as my selected language.  I even tried making two changes at a time, one to the language selection and one to something else, then doing the same in reverse to get back to, I hoped, english_gb, but even this did not work - the log showed that only the other change had been written to the database.

Is this a general problem, that selecting your default language in the config panel does not select that language, and leaves you with the last language selected?  Or is it unique to english_gb?

Is this a known issue?  I have searched but not found anything.  It is not really serious, but it isa annoying that I cannot select english_gb. even though my config panel shows that I have apparently done just that.

Graham 

Graham
Logged

Graham66

  • Coppermine newbie
  • Offline Offline
  • Posts: 10
Re: New user admin notification email details
« Reply #5 on: April 21, 2009, 11:57:38 pm »

Having gone through all of this, I found this thread:  http://forum.coppermine-gallery.net/index.php/topic,32409.0.html - don't know why I did not find it first (or even second) time.  GauGau did say that only 2% of the 1% of users concerned about the point would find it, so I guess I was quite lucky actually!

What I cannot test without changing my default language on my computer, which I am disinclined to do at preset, is whether auto-detect will determine the language in which notification emails are sent out.  If I try to set the language to english_gb, then I want all email notifications to the administrator to be sent out to me in that language.  I suspect that the effect of autodetect is that if a new user in Spain registers, I get a Spanish email.  And if I have made modifications to my template to give information based on what the user has entered on registration (see my original post), I would like to be able to see that without having to make the same modification to the email template in every language file.

If (and I stress if - I am not sure) that is the result of auto-detect, then it would be a good thing to be able to disable it as an admin option.  Since I am not likely to get any overseas users, I will probably not apply Stramm's fix for this, but I can see that there might be rather more call for this than might first be imagined.

Graham
Logged

Joachim Müller

  • Dev Team member
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 47843
  • aka "GauGau"
    • gaugau.de
Re: New user admin notification email details
« Reply #6 on: April 22, 2009, 06:56:00 pm »

In an ideal world, the language of a notification email would be in the language of the recipient. That's currently not the case (known issue though): the email is sent in the language of the sender.
Logged
Pages: [1]   Go Up
 

Page created in 0.024 seconds with 20 queries.