The gform_userregistration_associate_entry_with_user filter is used to determine if a form entry should be associated with the newly created user.
Usage
add_filter('gform_userregistration_associate_entry_with_user', 'your_function_name', 10, 5);
Parameters
- $update_entry_creator (bool): If entry creator should be associated with user.
- $user_id (int): New user ID.
- $feed (Feed Object): The current feed.
- $entry (Entry Object): The current entry.
- $form (Form Object): The current form.
More information
See Gravity Forms Docs: gform_userregistration_associate_entry_with_user
This filter was added in User Registration version 4.0.9. It is located in GF_User_Registration::create_user() in gravityformsuserregistration/class-gf-user-registration.php
.
Examples
Always associate entry with user
In this example, the entry will always be associated with the newly created user.
add_filter('gform_userregistration_associate_entry_with_user', 'always_associate_entry', 10, 5); function always_associate_entry($update_entry_creator, $user_id, $feed, $entry, $form) { return true; }
Associate entry with user based on a specific form
In this example, the entry will be associated with the newly created user only if the form ID is 5.
add_filter('gform_userregistration_associate_entry_with_user', 'associate_entry_for_form', 10, 5); function associate_entry_for_form($update_entry_creator, $user_id, $feed, $entry, $form) { return $form['id'] == 5; }
Associate entry with user based on a specific field value
In this example, the entry will be associated with the newly created user only if the value of field with ID 10 is “Yes”.
add_filter('gform_userregistration_associate_entry_with_user', 'associate_entry_based_on_field', 10, 5); function associate_entry_based_on_field($update_entry_creator, $user_id, $feed, $entry, $form) { return rgar($entry, '10') == 'Yes'; }
Associate entry with user for a specific feed
In this example, the entry will be associated with the newly created user only if the feed ID is 3.
add_filter('gform_userregistration_associate_entry_with_user', 'associate_entry_for_feed', 10, 5); function associate_entry_for_feed($update_entry_creator, $user_id, $feed, $entry, $form) { return $feed['id'] == 3; }
Do not associate entry with user
In this example, the entry will never be associated with the newly created user.
add_filter('gform_userregistration_associate_entry_with_user', 'never_associate_entry', 10, 5); function never_associate_entry($update_entry_creator, $user_id, $feed, $entry, $form) { return false; }