Support

Account

Home Forums General Issues ACF + Gravity Forms User Registration

Solved

ACF + Gravity Forms User Registration

  • I’m using Gravity Forms User Registration Add-On to register users and assign them a case worker. In ACF Pro I have created a case_worker field (field_636957e952b06) with the Field Type set as User and the Return Format set to User Array. In my registration form I have a drop down field that I’m using Populate Anything to generate the list all of users with the case worker role, with the value set to User ID and the Label set to Display Name. In the User Registration Feed User Meta section the case_worker Key is assigned to the Case Worker field value. When the form is submitted and the user is registered, the backend has the correct case worker displayed on the user profile and the database case_worker meta_key has the correct user ID for the case worker set, but on the frontend the fields will not display with get_field unless I manually save the user profile in the admin. I know I need to save the value to the ACF field after the form is submitted, but so far I have been unsuccessful. This is my most current attempt, there have been many pieced together by scouring both ACF and gravity forms posts, I figured it was time to ask for some help…

    add_action( 'gform_after_submission_4', 'after_submission', 10, 2 );
    function save_additional_user_meta( $user_id ) {
    
    	$user = wp_insert_user( $userdata );
    	update_field('field_636957e952b06', $case_worker, 'user_'.$user);
    
    }
  • I finally figured it out! And corrected my embarrassing mistake in the function above…

    add_action( 'gform_user_registered', 'save_additional_user_meta', 10, 4 );
    function save_additional_user_meta ($user_id, $feed, $entry) {
    
    	$case_worker = rgar( $entry, '4' );
    	update_field('field_636957e952b06', $case_worker, 'user_'.$user_id);
    
    }
Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.