Forums

Unfortunately no one can be told what FluxBB is - you have to see it for yourself.

You are not logged in.

#1 2013-04-29 11:14:31

Squiggles
Member
Registered: 2012-12-14
Posts: 278

Welcome Email after Regstration (No Activation)

When "Verify registrations" is enabled, users receive a Welcome / Activation email but... I would like all new user registrations to receive a Welcome email when "Verify registrations" is disabled.

I have created a welcome_no_activation.tpl under lang/English/mail_templates and modified the register.php to the following

// Must the user verify the registration or do we log him/her in right now?
		if ($pun_config['o_regs_verify'] == '1')
		{
			// Load the "welcome" template
			$mail_tpl = trim(file_get_contents(PUN_ROOT.'lang/'.$pun_user['language'].'/mail_templates/welcome.tpl'));

			// The first row contains the subject
			$first_crlf = strpos($mail_tpl, "\n");
			$mail_subject = trim(substr($mail_tpl, 8, $first_crlf-8));
			$mail_message = trim(substr($mail_tpl, $first_crlf));

			$mail_subject = str_replace('<board_title>', $pun_config['o_board_title'], $mail_subject);
			$mail_message = str_replace('<base_url>', get_base_url().'/', $mail_message);
			$mail_message = str_replace('<username>', $username, $mail_message);
			$mail_message = str_replace('<password>', $password1, $mail_message);
			$mail_message = str_replace('<login_url>', get_base_url().'/login.php', $mail_message);
			$mail_message = str_replace('<board_mailer>', $pun_config['o_board_title'], $mail_message);

			pun_mail($email1, $mail_subject, $mail_message);

			message($lang_register['Reg email'].' <a href="mailto:'.$pun_config['o_admin_email'].'">'.$pun_config['o_admin_email'].'</a>.', true);
		}
		else if ($pun_config['o_regs_verify'] == '0')
		{
		// Load the "welcome_no_activation" template
			$mail_tpl = trim(file_get_contents(PUN_ROOT.'lang/'.$pun_user['language'].'/mail_templates/welcome_no_activation.tpl'));

			// The first row contains the subject
			$first_crlf = strpos($mail_tpl, "\n");
			$mail_subject = trim(substr($mail_tpl, 8, $first_crlf-8));
			$mail_message = trim(substr($mail_tpl, $first_crlf));

			$mail_subject = str_replace('<board_title>', $pun_config['o_board_title'], $mail_subject);
			$mail_message = str_replace('<base_url>', get_base_url().'/', $mail_message);
			$mail_message = str_replace('<username>', $username, $mail_message);
			$mail_message = str_replace('<password>', $password1, $mail_message);
			$mail_message = str_replace('<login_url>', get_base_url().'/login.php', $mail_message);
			$mail_message = str_replace('<board_mailer>', $pun_config['o_board_title'], $mail_message);

			pun_mail($email1, $mail_subject, $mail_message);

			message($lang_register['Reg email'].' <a href="mailto:'.$pun_config['o_admin_email'].'">'.$pun_config['o_admin_email'].'</a>.', true);
			}

This resulted in the user to receive a welcome email but it doesnt automatically log the user in.

So my question is... How can I automatically send a welcome email to users upon registration when the "verfify registration" option is disabled, but also login them in automatically on registration?

Cheers,
Squiggles

Last edited by Squiggles (2013-04-29 11:26:35)

Offline

#2 2013-04-30 17:19:18

Franz
Lead developer
From: Germany
Registered: 2008-05-13
Posts: 6,639
Website

Re: Welcome Email after Regstration (No Activation)

You need to add this line to your code before exiting (which the message() function does automatically):

pun_setcookie($new_uid, $password_hash, time() + $pun_config['o_timeout_visit']);

fluxbb.de | develoPHP

"As code is more often read than written it's really important to write clean code."

Offline

#3 2013-05-01 00:39:19

Squiggles
Member
Registered: 2012-12-14
Posts: 278

Re: Welcome Email after Regstration (No Activation)

Thanks Franz, but I'm not really sure where to put that line of code?

Offline

#4 2013-05-01 01:58:53

Franz
Lead developer
From: Germany
Registered: 2008-05-13
Posts: 6,639
Website

Re: Welcome Email after Regstration (No Activation)

Right above the second-to-last line you posted (the one that starts with "message").


fluxbb.de | develoPHP

"As code is more often read than written it's really important to write clean code."

Offline

#5 2013-05-02 04:40:37

Squiggles
Member
Registered: 2012-12-14
Posts: 278

Re: Welcome Email after Regstration (No Activation)

Thanks Franz, I got it sort of working.

After registration, it displays the usual "your password has been sent to...." message, and the user is required to click on a tab (such as index) in order to be automatically logged in.

Is there anyway to bypass that message and take the user straight to the forum home page?

Offline

#6 2013-05-06 05:58:23

Franz
Lead developer
From: Germany
Registered: 2008-05-13
Posts: 6,639
Website

Re: Welcome Email after Regstration (No Activation)

You can use the redirect() method instead of the message() method. Just check how it is used in other places throughout the code.


fluxbb.de | develoPHP

"As code is more often read than written it's really important to write clean code."

Offline

Board footer

Powered by FluxBB