Home / Widgets / Forms ACF Add-On
Duplicate Snippet

Embed Snippet on Your Site

Forms ACF Add-On

Populate Forminator forms with user's ACF data

<10
Code Preview
php
<?php
add_filter( 'forminator_render_fields_markup', 
function( $html, $wrappers ){ 
    $replacements = array( 
'%my_value_1%' => '',
'%my_value_2%' => '',
'%my_value_3%' => '',
'%my_value_4%' => '',
);
if ( is_user_logged_in() ) { $current_user = wp_get_current_user(); 
$replacements = array( 
'%my_value_1%' => get_user_meta( $current_user->ID, 'field_1', true ), 
'%my_value_2%' => get_user_meta( $current_user->ID, 'field_2', true ), 
'%my_value_3%' => get_user_meta( $current_user->ID, 'field_3', true ), 
'%my_value_4%' => get_user_meta( $current_user->ID, 'field_4', true ), 
 );  }  
return str_replace( array_keys( $replacements ), array_values( 
    $replacements ), $html ); 
},  
20, 
2 
);

Comments

Add a Comment