-1

I'm building a registration form in Concrete5 but beforehand I need to retreive the User Attributes.

I'm using hidden input to get the values as so:

<input type="hidden" name="akID[<?php echo UserAttributeKey::getByHandle('school')->getAttributeKeyID(); ?>][value]" value='<?php echo $_POST['full_name']; ?>'/>

However I can only get the value if I make a mistake beforehand, i.e. incorrect confirm password and then resubmit the form.

Any ideas on how to get the values without doing this?

Kind Regards

Frog82
  • 464
  • 1
  • 8
  • 25
  • If i understood your question correctly, you want to check whether the `password` and `confirm password` fields values are same or not.. For it, you can use JavaScript or JQuery to achieve it... – phpfresher Mar 06 '15 at 12:46
  • @phpfresher Sorry, its a hard question to try to explain, I have to force an error during registration and then resubmit the form inorder for these values to be set – Frog82 Mar 06 '15 at 12:48
  • You mean, it has to show an error and then the form has to submit automatically ????? – phpfresher Mar 06 '15 at 12:52
  • @phpfresher Validation will kick in when they notice there is an error, I then complete validation and then manually press the submit button, which will then display set these attributes. However, I dont want to force an error, I just want the attributes to be sent on first submission. I think its something to do with $_POST or the way I get the value from the other textbox – Frog82 Mar 06 '15 at 12:55

1 Answers1

0

Your example is a bit confusing.

First let me explain why it doesn't work the way you want it to.

You are giving your hidden field a value from $_POST. $_POST only exists once you actually post the form. So on first load of the page, $_POST doesn't exist so $_POST['full_name'] is null. When you submit the form and there is an error however, the same page reloads but this time $_POST exists since the page reloads after submitting the form.

Here's what is confusing. If on reload $_POST['full_name'] has a value it means you already have a 'full_name' field probably as a text input box. Why then do you want to have a hidden field with the exact same value?

If what you want in this hidden field is the value of a user attribute you need to do 2 things: 1- make sure the user is logged in, else no attributes are available 2- get the user info object to get the attribute value from like so:

$u = new User();
$ui = UserInfo::getByID($u->getUserID());

2- modify the value of the hidden field like so:

value="<?php echo $ui->getAttribute('attribute_handle'); ?>"
Nour Akalay
  • 429
  • 3
  • 4