Support

Account

Home Forums General Issues How to update acf field value for wp user Reply To: How to update acf field value for wp user

  • @hube2 I tried this but I can’t get it to work and I am not exactly sure how to go about writing this. Can you give me some pointers?

    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;
    		$field_key = 'user_company';
    		list($user, $domain) = explode('@', $args['user_email'] );
    		if ($domain == 'amyling.com') {
    			$company = $user_company->post_title('Pearlsin Arts');
    			update_field($field_key, $company, 'user_' . $user_id);
    		};
    }