Default field value from shortcode
-
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]
The topic ‘Default field value from shortcode’ is closed to new replies.