Jump to content

Hereward

Members
  • Posts

    2
  • Joined

  • Last visited

Hereward's Achievements

Newbie

Newbie (2/6)

0

Reputation

  1. Acutally I just realised my mistake > "wire('fu')->userObj->myField" . All good. Working now.
  2. Hi, I have have added an extra field for registration as per your instructions in Code snippets, however the field data is missing after registration is completed. I have updated the relevant template in admin so that "firstname" is now a user field, and this is working fine. My code is all working ok but the "firstname" field remains empty upon registration. I can only manually update it through admin. ProcessWire 2.7.1 FrontendUser 0.8.9 My code is posted below. $fu = $modules->get('FrontendUser'); $FirstName = $modules->get('InputfieldText'); $FirstName->label = $this->_('First Name'); $FirstName->attr('id+name', 'firstname'); //$FirstName->required = 1; $FirstName->fhSanitizer = 'text'; // Call hook after field is processed by PW form api $FirstName->addHookAfter('processInput', function($event) { $field = $event->object; // Value will be sanitized as text with "$sanitizer->text()" $mySanitizedCustomInput = wire('fu')->form->fhValue($field->name); // Do ... // Example: Add value to user during registration wire('fu')->userObj->myField = $mySanitizedCustomInput; // Need to set an field error? // $field->error('Custom field has an error...'); }); // Define the field before you call FU and add it as additional field... $fu->register(array('username', 'email', 'password', $FirstName)); //$fu->register(); $fu->process("/member-area/login/"); echo $fu->render();
×
×
  • Create New...