rash Posted March 30, 2021 Posted March 30, 2021 Hi all, I’m building a simple frontend login system for a specific role, using the LoginRegister module. I want users of this role to login with email and password, which is working just fine. I would also like to allow those users to change their password, but not their email address. In the LoginRegister config I obvioulsy can’t get rid of the email and password field, so there is no option to limit the profile fields to password only. I tried it with the following (quick’n dirty) hook: wire()->addHookAfter('LoginRegister::buildProfileForm', function(HookEvent $event) { $form = $event->return; $email_field = $form->getChildByName('profile_email'); $form->remove($email_field); $event->return = $form; }); First it seems to do the trick, as there is no email field displayed anymore, but after submitting the form I get Uncaught Error: Call to a member function val() on null in /…/site/modules/LoginRegister/LoginRegister.module:913. I guess an email value is expected, so I tried to submit it separately: wire()->addHookAfter('LoginRegister::buildProfileForm', function(HookEvent $event) { $form = $event->return; $email_field = $form->getChildByName('profile_email'); $form->remove($email_field); $usermail = $event->wire('user')->email; $email_field->value = $usermail; $event->return = $form; }); No luck, the error stays the same. Is there a more intelligent way to limit the profile edit options to password and nothing else?
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now