Skip Navigation

[Resolved] Register > Woocommece checkout Fatal error

This support ticket is created 2 years, 9 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Karachi (GMT+05:00)

This topic contains 4 replies, has 2 voices.

Last updated by TomW5440 2 years, 9 months ago.

Assisted by: Waqar.

Author
Posts
#2345407

Is there any documentation that you are following?
https://toolset.com/lesson-placement/lesson-placements-1645361-1651293/

Tell us what you are trying to do?
Set register form to go to checkout on submit. I followed the documentation but get a fatal error message when submitting new user form.

Fatal error: Uncaught InvalidArgumentException: All provided arguments for a related element must be either an ID or a WP_Post object. in /home/alwaysre/public_html/wp-content/plugins/toolset-blocks/vendor/toolset/toolset-common/inc/autoloaded/interop/commands/RelatedPosts.php:246 Stack trace: #0 /home/alwaysre/public_html/wp-content/plugins/toolset-blocks/vendor/toolset/toolset-common/inc/autoloaded/interop/commands/RelatedPosts.php(177): OTGS\Toolset\Common\Interop\Commands\RelatedPosts->set_query_by_elements(Array, 'child') #1 /home/alwaysre/public_html/wp-content/plugins/toolset-blocks/vendor/toolset/toolset-common/inc/public_api/m2m.php(159): OTGS\Toolset\Common\Interop\Commands\RelatedPosts->__construct('draft_0', 'member-comment', Array) #2 /home/alwaysre/public_html/wp-content/toolset-customizations/redirect_hook.php(12): toolset_get_related_post('draft_0', 'member-comment') #3 /home/alwaysre/public_html/wp-includes/class-wp-hook.php(307): custom_redirect('hidden link...', 'draft_0', Array) #4 /home/alwaysre/p in /home/alwaysre/public_html/wp-content/plugins/toolset-blocks/vendor/toolset/toolset-common/inc/autoloaded/interop/commands/RelatedPosts.php on line 246

#2345895

Hi,

Thank you for contacting us and I'd be happy to assist.

From the error message, it seems that the custom code added in the Toolset's custom code snippet "redirect_hook" is responsible for this.

Can you please share temporary admin login details, along with the link to this registration page? I'll be able to see how the form and the custom code snippet are configured and suggest the next steps, accordingly.

Note: Your next reply will be private and it is recommended to make a complete backup copy, before sharing the access details.

regards,
Waqar

#2346019
toolset1.jpg

I'm not sure if this is related but I've got another error on the checkout page

Notice: Trying to access array offset on value of type null in /home/alwaysre/public_html/wp-content/plugins/cred-commerce/classes/CRED_Commerce.php on line 886

The first column is only 8% wide. Screen print attached.

#2347177

Thank you for sharing the admin access.

I noticed that in the custom code snippet named "redirect_hook", the code to get the related parent "Member" post was added in a way that it executes for all the forms and not just for the intended form "Edit comment" (ID: 434).
( screenshot: hidden link )

As a result, when other forms are submitted, it results in an error. To make code execute only for that particular form, please update it to:


add_filter('cred_success_redirect', 'custom_redirect',10,3);
function custom_redirect($url, $post_id, $form_data)
{
	if ($form_data['id']==434) {
		$parent_id = toolset_get_related_post( $post_id, 'member-comment' );
		$parent_url = get_permalink($parent_id);
		return $parent_url;
	}

	return $url;
}

This should fix the errors.

#2348079

My issue is resolved now. Thank you!