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 Finally getting back to this, it’s been so long that I have to try and remember what I was doing.

    So per my last code:

    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');
    		};
    	}
    }

    If I were to change ‘Pearlsin Arts’ to the post ID, would that then work or I still need query the company posts?