• Resolved pccjenny

    (@pccjenny)


    Hi, I’m using the Ultimate Member plugin and I have a working shortcode which will display the phone number of a logged in user on any page. But I want to display it as the default field value for the phone number field on my Easy Form Builder form. Since it can’t be directly entered as the default value, I’ve tried different scripts to dynamically insert it but I haven’t gotten anything to work. My current unsuccessful php code is:

    // Add this code to your theme's functions.php file or a custom plugin.
    add_filter('easy_form_builder_field_default_value', 'insert_shortcode_into_default_value', 10, 2);

    function insert_shortcode_into_default_value($default_value, $field) {
    // Check if the field ID or type matches your target field
    if ($field['id'] === '6ik7dq981_') { // Replace 'your_field_id' with the actual field ID
    // Execute the shortcode and set it as the default value
    $default_value = do_shortcode('[um_loggedin show_lock="no"] {usermeta:mobile_number} [/um_loggedin]'); // Replace 'your_shortcode' with your actual shortcode
    }
    return $default_value;
    }

    Do you know why it isn’t working? Is “easy_form_builder_field_default_value” a valid filter hook?

    Thank you

    The page I need help with: [log in to see the link]

Viewing 1 replies (of 1 total)
  • Plugin Author hassantafreshi

    (@hassantafreshi)

    Hi, Just a quick note — easy_form_builder_field_default_value is not a registered filter hook in the Easy Form Builder plugin. That’s why your current PHP snippet isn’t applying as expected.

    In Easy Form Builder, default field values are typically managed client-side via JavaScript after the form is fully loaded. To dynamically populate a field (e.g. with the logged-in user’s phone number), you’d need to use a custom JavaScript script that runs post-render and injects the value into the appropriate field input.

    If you’d rather not deal with custom coding, we’d be happy to implement this for you. With the Pro + Support plan Easy Form Builder, our team can handle the integration for you — saving you time and hassle.

    Let us know how you’d like to proceed!

    Best regards

Viewing 1 replies (of 1 total)

The topic ‘Default field value from shortcode’ is closed to new replies.