Home › Forums › Front-end Issues › ACF_form User Profile editing › Reply To: ACF_form User Profile editing
Hi guys thanks for replying.
Sadly I still can’t figure this one out 🙁 I’ve switched it to use the field key and changed the priority to 10 and now when I submit the form I get a white screen (500). I’ve even tried setting the field type from text to url.
It’s got me stumped this one because is works so well for the email field.
Here’s the updated code:
function my_acf_save_post_url( $post_id ) {
// bail early if no ACF data
if( empty($_POST['acf']) ) {
return;
}
// bail early if editing in admin
if( is_admin() ) {
return;
}
if( $_POST['post_id'] != 'new' ) {
$urlField = $_POST['acf']['field_57861544dfb0f'];
$wp_user_id = str_replace("user_", "", $post_id);
if (isset($urlField)) {
if (url_exists( $urlField )){
// Email exists, do not update value.
// Maybe output a warning.
update_field('field_57861544dfb0f', get_the_author_meta('user_url',$wp_user_id), $post_id);
} else {
$args = array(
'ID' => $wp_user_id,
'user_url' => esc_attr( $urlField )
);
wp_update_user( $args );
}
}
}
// return the ID
return $post_id;
}
add_action('acf/save_post', 'my_acf_save_post_url', 10);
Could I be missing something in my form options:
$options = array(
'post_id' => 'user_'.$current_user->ID, // $user_profile,
'field_groups' => array(225),
'submit_value' => 'Update Profile',
'uploader' => 'basic'
);
Thanks for your help, very much appreciated.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.