Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for "GP Unique ID" (gp-unique-id) plugin (perk) #38

Open
remcotolsma opened this issue Dec 20, 2023 · 2 comments
Open

Add support for "GP Unique ID" (gp-unique-id) plugin (perk) #38

remcotolsma opened this issue Dec 20, 2023 · 2 comments

Comments

@remcotolsma
Copy link
Member

If I search for "GP Unique ID" within our support system, I get 21 results. Should we consider adding support for the "GP Unique ID" plugin (perk)? Now sometimes we throw the following gist over the fence: https://gist.github.com/rvdsteege/6b0afe10f81b1bc99d335ff484206fa9. According to the FAQ at https://gravitywiz.com/documentation/gravity-forms-unique-id/#can-unique-id-generation-be-delayed-until-after-payment-is-approved I would expect it to be already should work.

Can Unique ID generation be delayed until after payment is approved?

If your form uses a first-party payment add-on (or a third-party payment add-on compatible with the Gravity Forms Payment Add-On Framework) then the unique ID can be generated once payment has been captured. This delay is enabled via the gpui_wait_for_payment filter.

Based on this FAQ you get the impression that it should work automatically, or should a programmer still hook into the gpui_wait_for_payment filter with custom code? A user of the Pronamic Pay plugin may inquire with Gravity Wiz how this works, see following ticket:

Internal HelpScout ticket: https://secure.helpscout.net/conversation/2457184606/26664/

I did see that the "GP Unique ID" plugin is equipped with specific code for the Gravity Forms PayPal add-on:
https://github.com/pronamic/gp-unique-id/blob/main/includes/class-gf-field-unique-id.php#L43-L45

The "GP Unique ID" plugin also doesn't seem to work with Gravity Forms feeds, but with a "Unique ID" field, which is probably why it doesn't work as I would expect.


localhost_8888_wp-admin_admin php_page=gf_edit_forms id=1


localhost_8888_wp-admin_admin-php_page-gf_edit_forms-view-settings-subview-pronamic_pay-id-1-fid-0

CC @rvdsteege

@rvdsteege
Copy link
Member

Hmm, the faq seems a bit unclear indeed. Sounds like gpui_wait_for_payment always needs to be used to make GP Unique ID "wait for payment".

We've had contact with @spivurno in the past (2020) regarding compatibility between Pronamic Pay and GP Unique ID and have added the pronamic_pay_gravityforms_delay_actions filter back then. In response we received:

Amazing! I'll dig in this week. Thanks for the follow-up!

…but I'm not sure if this has ever been implemented within GP Unique ID. It's a pity that GP Unique ID cannot work with the delayed payment support:

/**
* Filters the delay actions to display on the payment feed settings page and to process.
*
* @since 2.4.0
*
* @link https://github.com/wp-premium/gravityforms/blob/2.4.17/print-entry.php#L148-L163
* @link https://github.com/phpDocumentor/phpDocumentor/issues/1712
*
* @param array $actions {
*
* Delay action.
*
* @var null|\GFAddon $addon Optional reference to a Gravity Forms add-on object.
* @var bool $active Boolean flag to indicate the delay action can be enabled (add-on active).
* @var string $meta_key Post meta key used to store meta value if the delay action is enabled.
* @var bool $delayed_payment_integration Boolean flag to indicate the delay action is defined by a delayed payment integration.
* @var string $label The label to show on the payment feed settings page.
* @var callable $delay_callback Callback function which can be used to remove actions/filters to delay actions.
* @var callable $process_callback Callback function to process the delay action.
*
* }
*/
$actions = \apply_filters( 'pronamic_pay_gravityforms_delay_actions', $actions );

Would be nice if we don't have to mention the Gist anymore in the future!

Internal Help Scout ticket: https://secure.helpscout.net/conversation/1149426959/19687

@kjtolsma
Copy link
Member

Solution from Gravity Wiz:

add_action( 'gform_ideal_fulfillment', function( $entry ) {
	$form = GFAPI::get_form( $entry['form_id'] );

	foreach ( $form['fields'] as $field ) {
		if ( $field->get_input_type() != 'uid' ) {
			continue;
		}

		$value = gp_unique_id()->get_unique( $form['id'], $field, 5, array(), $entry, false ); // last param as false to trigger Unique ID generation even for spam entries

		$entry[ $field['id'] ] = $value;

		GFAPI::update_entry( $entry );
	}
}, 9 );

Internal Help Scout ticket: https://secure.helpscout.net/conversation/1149426959/19687

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Todo
Status: Todo
Development

No branches or pull requests

3 participants