Prepopulating embedded wordpress forms with user data

Using our URL Parameters feature, you can dynamically add logged-in user information, such as name and email to an embedded form on your WordPress website. Coupled with the ability to hide fields when a URL parameter is provided, you can create clean and minimalist forms while still collecting all necessary information.

Step 1: Create the Form

Start by creating the form. Use a board with the following four columns:

  • Item (Item name column)

  • Description (Long text column)

  • Email (Email column)

  • User Name (Text column)

Click to view in full screen

Next, create and style an Easyform with all four questions:

Click to view in full screen

Step 2: Pre-fill the Form with URL Parameters

To pre-fill a form using URL parameters, you’ll need to get the column IDs for the pre-filled columns. Additionally, obtain the share URL of the Easyform.

Step 3: Embed the Easyform in WordPress

In the WordPress editor, navigate to: AppearanceTheme File EditorTheme Functions.

Add the following embed code at the bottom of the file. Be sure to replace the placeholder variables—FORM_NAME, EASYFORM_URL, USER_NAME_COLUMN_ID, and USER_EMAIL_COLUMN_ID—with their appropriate values:

add_shortcode('FORM_NAME', function() {
    $current_user = wp_get_current_user();
    $user_email = $current_user->user_email;
    $user_name = $current_user->display_name;
    
    return '<script src="https://eazyform.app/js/set-embedded-eazyform-height.js"></script>
    <iframe class="eazyform-embed eazyform-dynamic-height" 
    src="EASYFORM_URL?embedded=1&autoheight=1&USER_EMAIL_COLUMN_ID=' . esc_attr($user_email) . '&USER_NAME_COLUMN_ID=' . esc_attr($user_name) . '" 
    frameborder="0" 
    onmousewheel="" 
    scrolling="no" 
    style="background-color: transparent; border-width: 0; margin: 0; padding: 0; width: 1px; min-width: 100%;"></iframe>';
});

Click Update File to save your changes:

Click to view in full screen

Step 4: Add the Easyform to a Page

On the WordPress page where you want to embed the form:

  1. Add a Custom HTML block.

  2. Enter the FORM_NAME shortcode in square brackets (e.g., [eazyform_iframe]).

Click to view in full screen

Then, when a logged-in user loads the page, their name and email will populate the form.

Click to view in full screen

To hide the pre-filled fields, enable the "Hide field when URL parameter is provided" feature in your Easyform settings

Last updated