Hello @markovetski ,
I’m sorry for the late response. I have tested code for the Forminator with ACF and it works correctly.
This is code I’m using for the mu-plugin:
<?php
add_filter(
'forminator_field_markup',
function( $html ) {
if ( is_user_logged_in() ) {
$company = get_field( 'myfield' );
if ( ! empty( $company ) ) {
$html = str_replace( '%my_value_1%', $company, $html );
}
} else {
$html = str_replace( '%my_value_1%', '', $html );
}
return $html;
},
99
);
my custom field is myfield.
Please note that this code has condtion for the logged-in user:
if ( is_user_logged_in() ) {
This exported simple form with this field:
{"type":"form","data":{"fields":[{"id":"text-1","element_id":"text-1","form_id":"wrapper-1763-5888","type":"text","options":[],"cols":12,"conditions":[],"wrapper_id":"wrapper-1763-5888","input_type":"line","limit_type":"characters","field_label":"Text","placeholder":"E.g. text placeholder","default":"%my_value_1%"}],"settings":{"formName":"afcfields","pagination-header":"nav","version":"1.10.2","form-border-style":"none","form-padding":"","form-border":"","fields-style":"open","validation":"on_submit","form-style":"default","enable-ajax":"true","autoclose":"true","submission-indicator":"show","indicator-label":"Submitting...","paginationData":{"pagination-header-design":"show","pagination-header":"nav"},"submission-behaviour":"behaviour-thankyou","thankyou-message":"Thank you for contacting us, we will be in touch shortly.","submitData":{"custom-submit-text":"Send Message","custom-invalid-form-message":"Error: Your form is not valid, please fix the errors!"},"validation-inline":"1","form-expire":"no_expire","form-padding-top":"0","form-padding-right":"0","form-padding-bottom":"0","form-padding-left":"0","form-border-width":"0","form-border-radius":"0","cform-label-font-family":"Roboto","cform-label-custom-family":"","cform-label-font-size":"12","cform-label-font-weight":"bold","cform-title-font-family":"Roboto","cform-title-custom-family":"","cform-title-font-size":"45","cform-title-font-weight":"normal","cform-title-text-align":"left","cform-subtitle-font-family":"Roboto","cform-subtitle-custom-font":"","cform-subtitle-font-size":"18","cform-subtitle-font-weight":"normal","cform-subtitle-text-align":"left","cform-input-font-family":"Roboto","cform-input-custom-font":"","cform-input-font-size":"16","cform-input-font-weight":"normal","cform-radio-font-family":"Roboto","cform-radio-custom-font":"","cform-radio-font-size":"14","cform-radio-font-weight":"normal","cform-select-font-family":"Roboto","cform-select-custom-family":"","cform-select-font-size":"16","cform-select-font-weight":"normal","cform-multiselect-font-family":"Roboto","cform-multiselect-custom-font":"","cform-multiselect-font-size":"16","cform-multiselect-font-weight":"normal","cform-dropdown-font-family":"Roboto","cform-dropdown-custom-font":"","cform-dropdown-font-size":"16","cform-dropdown-font-weight":"normal","cform-calendar-font-family":"Roboto","cform-calendar-custom-font":"","cform-calendar-font-size":"13","cform-calendar-font-weight":"normal","cform-button-font-family":"Roboto","cform-button-custom-font":"","cform-button-font-size":"14","cform-button-font-weight":"500","cform-timeline-font-family":"Roboto","cform-timeline-custom-font":"","cform-timeline-font-size":"12","cform-timeline-font-weight":"normal","cform-pagination-font-family":"","cform-pagination-custom-font":"","cform-pagination-font-size":"16","cform-pagination-font-weight":"normal","payment_require_ssl":"","submission-file":"delete"},"client_id":null,"notifications":[{"slug":"notification-1234-4567","label":"Admin Email","email-recipients":"default","recipients":"[email protected]","email-subject":"New Form Entry #{submission_id} for {form_name}","email-editor":"You have a new website form submission: <br/> {all_fields} <br/>---<br/> This message was sent from {site_url}."}]},"status":"publish","version":"1.10.2"}
This is how the field looks like on front end:
inside there is the value from the custom field that was added to the post.
kind regards,
Kasia