Home › Forums › General Issues › How to update acf field value for wp user › Reply To: How to update acf field value for wp user
I also tried this but doesn’t work. when I update the code in functions.php, I just go to the user’s profile in the backend and refresh the page to see if the relationship field has been updated but it stays on “Select”.
add_action( 'profile_update', 'update_user_company' );
add_action( 'personal_options_update', 'update_user_company' );
add_action( 'edit_user_profile_update', 'update_user_company' );
function update_user_company( $user_id, $args ) {
$user = get_user_by( 'ID', $user_id );
$email = $user->user_email;
$company = get_field( 'user_company', 'user_' . $user_id );
if ($company == '') {
list($user, $domain) = explode('@', $args['user_email'] );
if ($domain == 'amyling.com') {
update_field( 'user_company', 'Pearlsin Arts');
};
}
}
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.