Hello,
I am using the Login.Register extra for my website’s registration page, and when I add a posthook to the chunk, the form’s submit button redirects to a blank page. Without any posthooks, the chunk works as it should, and a user is able to register, is sent an activation email, and is redirected to the email verification page. I want to use a posthook to send another email to an admin to notify them of the new user sign up, but when I add the posthook to send the second email, both emails successfully send to the new user and the admin, however the user is redirected to a blank page instead of the email verification page and the following error is logged:
PHP Fatal error: Uncaught Error: Call to a member function get() on array in /home4/zwyxwmmy/public_html/core/components/login/processors/register.php:413
I also tried using the f12 network tab to try to inspect the requests being sent when I submit the form, and I see that there is a POST request with a 500 error and a GET request to the website’s 404 page.
Here is the Register chunk that I am using:
[[!Register?
&submitVar=`registerbtn`
&activationResourceId=`***`
&activationEmailTpl=`form-activiation-email-tpl`
&activationEmailSubject=`***`
&errTpl=`<p>ERROR</p>`
&submittedResourceId=`***`
&usergroups=`***`
&validate=`nospam:blank,
username:required,
email:password_confirm=^username^,
password:required:minLength=^6^,
password_confirm:password_confirm=^password^,
fullname:required`
&placeholderPrefix=`reg.`
&postHooks=`hookAdminEmail`
]]
And this is the code from the hookAdminEmail snippet:
<?php
$headers .= "From: ***\n";
$headers .= "BCC:\n";
$headers .= "Content-Type: text/html; charset=iso-8859-1\n"; //
$message = 'Hi, a new User signed up: '.$hook->getValue('username')
. ' with email '.$hook->getValue('email').'.';
$to = "***";
$subject = "New User Signed Up";
if (mail($to, $subject, $message, $headers)) {
return true;
} else {
return false;
}
However I believe that this error occurs regardless of what code is in the snippet, as I have tried out making the only code in the snippet the line return true;
to see if the page would display, but even with that simple snippet a blank page and logged error were returned from submitting the form.
Has anyone encountered a similar problem where posthooks stop a page from properly redirecting? Any help would be greatly appreciated.