This forum has moved to a new location and is in read-only mode. Please visit talk.octobercms.com to access the new location.
Hi,
I'm busy with a plugin, with this plugin you can extend the registration form with custom fields like datepicker, text, password, fileupload fields. But I'm not sure if it is possible to extend the onRegister method without copying the whole code.
So if you guys have any suggestions, thanks! :)
You can create another AJAX handler and then call the Account component from there.
[account]
==
public function onMyRegister()
{
// Do my custom things
$this['account']->onRegister();
}
Last updated
@daftspunk : Hi i have extended user table. Now how we will pass or save extra/extended fields/variables to onRegister so that it can be saved;
like $gender = post('gender');
if you look into the account component, you can check the onRegister method. all the post inputs are handled line 158
$data = post();
after a validation, all the fields are passed to the Auth::register method.
so basically you have to hook your own onRegister method before the Account component.
in your singup form in a page, you need to have this : form data-request="myRegisterMethod" instead f the standard form="onRegister" which is calling the account component method.
then still in the php section of your page, you will have your own code
public function myRegisterMethod() { // Do my custom things first thing first try { $data = post(); // at some point you need to call the original method $this['account']->onRegister(); // .... } catch (Exception $ex) { // do your own stuf when an error occurs // the account compoennt is throwing nice exception, we have to catch them and treat them here } }
hope that helps
Nope, doesn't help.
Using: $this['account']->onRegister();
Gives the error: "Call to a member function onRegister() on null()"
This syntax is now supported too, btw:
[account]
==
public function onMyRegister()
{
// Do my custom things
$this->account->onRegister();
}
And this is how you can check if registration has been successful by accessing the newly created user
object:
[account]
==
public function onMyRegister()
{
// Do my custom things
$this->account->onRegister();
$user = $this->account->user();
if($user)
{
return Redirect::to('home');
}
}
Last updated
or probably with the normal way it should work as well
if (!$user = Auth::getUser()) {
throw new \Exception('You must be logged in');
}
Hello All trying to do the same thing here new to Laravel and CMS these examples work for me how ever It is only do what it already did prior how do i add the new data "gender and date_of_birth" in my case to the profile table during registration.
I add the fields in the back-end and is working fine just need to add it in the front end any help is greatly appreciated
public function myRegisterMethod()
{
// Using the code form a user on this forum
// Do my custom things first thing first
try {
// Want to add this to the profile table
$data['gender'] = post('gender');
$data['date_of_birth'] = post('date_of_birth');
// call the original method
$this['account']->onRegister();
}
catch (Exception $ex) {
}
}
1-10 of 10