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 protected]

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

Black
3,4094 gold badges44 silver badges131 bronze badges
asked Feb 22, 2016 at 15:10

1 Answer 1

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)

answered Mar 30, 2016 at 21:23

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.