bookmark_bordergform_user_registration_update_user_id

Description

This filter can be used to override which user is used to populate the form and updated when the form is submitted.

Usage

The following would apply to all forms with an update type feed.

add_filter( 'gform_user_registration_update_user_id', 'your_function_name', 10, 4 );

To limit the scope of your function to a specific form, append the form id to the end of the hook name. (format: gform_user_registration_update_user_id_FORMID)

add_filter( 'gform_user_registration_update_user_id_6', 'your_function_name', 10, 4 );

Parameters

  • $user_id integer

    The ID of the user being used to populate the form and being updated on form submission.

  • $entry Entry Object

    The entry currently being processed or false when the form is being rendered.

  • $form

    The form currently being processed.

  • $feed Feed Object

    The feed currently being processed.

Example

The following example shows how you can override the user id with a specific id.

add_filter( 'gform_user_registration_update_user_id_6', 'override_user_id', 10, 4 );
function override_user_id( $user_id, $entry, $form, $feed ) {

    return is_user_logged_in() ? 13 : false;
}

Source

$user_id = gf_apply_filters( 'gform_user_registration_update_user_id', $form['id'], $user_id, $entry, $form, $feed );

This filter is located in the following methods in class-gf-user-registration.php.

  • GF_User_Registration::update_user() since 3.0.beta1
  • GF_User_Registration::maybe_prepopulate_form() since 3.0.beta1.3
  • GF_User_Registration::handle_existing_images_submission() since 3.0.beta1.3
  • GF_User_Registration::validate() since 3.0.beta1.3