2

We have a link in our footer that goes to a page with an embedded Formstack form. I understand how to pre-populate the form by editing the URL, but I'm unsure how to get the respective fields from Magento.

If the user is logged in to Magento, I would like to use their First Name, Last Name, and email address to pre-populate the respective fields in the formstack form.

In the end I need something like this

?firstname=John&lastname=Doe&email=jd@example.com

with the actual customer data. How can I retrieve this data within a CMS page?

2

While there are some dynamic variables that you can use in the CMS, it's not possible to get user information without custom code.

If you embed your form in a phtml template instead of a CMS page, you can include this template in the CMS:

{{block type="core/template" template="your/form.phtml"}}

In the template, you can use any PHP code like

$customer = Mage::getSingleton('customer/session')->getCustomer();
$firstname = $customer->getFirstname();

It would be best practice to move this code to a block class. Note that you can specify the block type as well, so instead of core/template you can use any other block.

But either way, you have to add the block type to the block whitelist in "System > Permissions > Blocks" to be able to use it in the CMS (see: https://magento.stackexchange.com/a/87897/243)

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.