Forum
Using Perch Members User Details In Perch Forms
Is it possible to use the Perch Members functions like echo perch_member_get('email');
inside a Perch Form I would like to pre-populate some hidden fields in a form that will be within the secure members area. I want to know that the form has been completed by a particular member and not on behalf of another member by adding their user details in a non editable way.
Hi Greg, yes, I think so.
You should be able to set the Member email as a variable and then pass it into the
perch_form
template.Something like this:
Then in your
form_template.html
template:Hi Simon, Thanks for idea but I can't get it to work it.
In page declaration.php I have:
then in declaration.html I have :
The form displays on page fine and submits but when I look in perch for form responses it has the mem_email as this_member_email
looks like it is not seeing it as a variable but as text once it gets to the form.
Sorry, try this in your template:
That is outputting some junk to the page
" />
so something not quite correct there. In the form results it still does not work but interestingly it is now leaving the mem_email value blank.Hi, are you using Perch 2, or 3?
Either way, I think this should do it...
Fantastic that works perfectly. So glad to have that working, I have been thinking of other sites where this would come in handy.
I am using Perch 2.8.34 on this site, I really should upgrade it to Runway version 3.
Many thanks for your help.
That's great.
You can even give it a label to show in the responses eg.
I often forget, when we're using Perch 2 we need to make sure we use XML-style self-closing tags in templates eg
In Perch 2 (or 3):
in Perch 3 only
Most of the code examples in Perch docs show the new Perch 3 'HTML5' style tags.
I have added the labels which make it much neater, and extended it to submit full name, and an additional member ID number. Along with displaying the information that will be submitted at the top of the page. I would share a link except it is of course in a members only area.
Thanks once again for your help Simon.