in web/wp-content/plugins/acf-extended/includes/modules/form/module-form-action-user.php [78:175]
function load_action($form, $action){
// check source
if(!$action['load']['source']){
return $form;
}
// apply template tags
acfe_apply_tags($action['load']['source'], array('context' => 'load', 'format' => false));
// vars
$load = $action['load'];
$user_id = acf_extract_var($load, 'source');
$user_role = acf_extract_var($load, 'role');
$acf_fields = acf_extract_var($load, 'acf_fields');
$acf_fields = acf_get_array($acf_fields);
$acf_fields_exclude = array();
// filters
$user_id = apply_filters("acfe/form/load_user_id", $user_id, $form, $action);
$user_id = apply_filters("acfe/form/load_user_id/form={$form['name']}", $user_id, $form, $action);
$user_id = apply_filters("acfe/form/load_user_id/action={$action['name']}", $user_id, $form, $action);
// bail early if no source
if(!$user_id){
return $form;
}
// get source user
$user = get_user_by('ID', $user_id);
// no user found
if(!$user){
return $form;
}
/**
* load user fields
*
* $load = array(
* user_email => 'field_655af3dd3bd56'
* user_login => 'field_655af3dd3bd56'
* user_pass => 'field_655af3dd3bd56'
* first_name => ''
* last_name => ''
* )
*/
foreach($load as $user_field => $field_key){
// check field is not hidden and has no value set in 'acfe/form/load_form'
if(acf_maybe_get($form['map'], $field_key) !== false && !isset($form['map'][ $field_key ]['value'])){
// check key exists in WP_User and is field key
if(in_array($user_field, $this->fields) && !empty($field_key) && is_string($field_key) && acf_is_field_key($field_key)){
// add field to excluded list
$acf_fields_exclude[] = $field_key;
// exclude password
if($user_field === 'user_pass'){
continue;
}
// assign user field as value
$form['map'][ $field_key ]['value'] = $user->{$user_field};
}
}
}
// load user role
if(!empty($user_role) && is_string($user_role) && acf_is_field_key($user_role)){
// field key
$field_key = $user_role;
// check field is not hidden and has no value set in 'acfe/form/load_form'
if(acf_maybe_get($form['map'], $field_key) !== false && !isset($form['map'][ $field_key ]['value'])){
// add field to excluded list
$acf_fields_exclude[] = $field_key;
// get roles
$form['map'][ $field_key ]['value'] = $user->roles;
}
}
// load acf values
$form = $this->load_acf_values($form, "user_{$user_id}", $acf_fields, $acf_fields_exclude);
// return
return $form;
}