Skip Navigation

[Resolved] Bypass Cred email verification

This support ticket is created 3 years, 10 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
- 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10: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/Kolkata (GMT+05:30)

This topic contains 26 replies, has 3 voices.

Last updated by Puntorosso 3 years, 9 months ago.

Assisted by: Minesh.

Author
Posts
#1970807

I think so. It should be part of the array $form_data, but that's undocumented. So, you will need to investigate it a bit and find out what data is in there. Note that a form is just a post, you can check its custom field to find out where that redirect page is stored and use it. Or you can just hardcode it in the custom code.

#1971513

Checked the source code

hidden link

So this should work, but sadly it doesn't

      	// Decide here where to redirect
      	$red_id = $form_data['action_page'];
        $redirect_url = site_url() . "/?page_id=" . $red_id[0];
        wp_redirect( $redirect_url );
        exit;

Any idea? Thanks

#1972049

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Jamal passed this ticket to me.

What if you try to use the WordPress function get_permalink() to get the link of the page based on the ID.

For example:

// Decide here where to redirect
$red_id = 4547;   // your page ID where you want to redirect 
$redirect_url = get_permalink($red_id);
wp_redirect( $redirect_url );
exit;
#1972093

Yes, I could do that, but then I could also hardcode the permalink.
I was trying to extract the redirection from the form settings, so I could use the same function for different forms.
Otherwise, I will have to duplicate the function for every form or use a IF/ELSE chain, as every form have a different redirection's page.

#1972115

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Can you please tell me under what hook you want to add that redirection code you shared?

#1972121

cred_form_validate

#1972135

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

$form_id = $form_data['id'];
$form_settings = get_post_meta($form_id,'_cred_form_settings',true);
$red_id = $form_settings->form['action_page'];   // getting redirect page ID from form settings
$redirect_url = get_permalink($red_id);
wp_redirect( $redirect_url );
exit;
#1972979

That works great! Thanks.

Now the only problem is that the form notification won't be sent, if the user exist.
Is it possible to "force" sending it?
As the user form won't be saved, I think we would need some way to trig the notification from the function.

#1973285

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Now the only problem is that the form notification won't be sent, if the user exist.
Is it possible to "force" sending it?
==>
Toolset email notification works when the form is successfully submitted.

I do not think or never seen ever that if you try to register and user is not available, only error message is displayed. I never seen that email is sent when you validate the user. Even if you check sites like facebook etc..etc.. you will see that validating user it will display only error message, it will not send email.

However - if you still want to send email, you may try to use the standard WordPress function: wp_mail()
- https://developer.wordpress.org/reference/functions/wp_mail/

#1973411

I think you may misunderstand the workflow of this form.

The form is used on single properties of a real estate site.
When a customer is interested on a particular property, he fills and submit the form, containing name and email fields.
At this point different things could happen:

- The user doesn't exist
In this case the user it's created and a custom post "inquiry" is added.
This inquiry post contains the property's object ID, number of rooms, price, etc. and this new user assigned as author.
The admin receives then a notification, triggered from the form submission, that a new inquiry and user has been added.

- The user exist
It can happen that a customer, which is already registered, it's interested on another property.
He fills the form again and submit.
At this point, we cannot add the user because it generates a "user exist" error, BUT we need anyway to create the new inquiry post and assign it to this user.
And even if the user it's not created, admin needs to know that a new inquiry post has been added.
But sadly the notification won't be sent because of the "user exist" error.

Does that make sense now?

#1973435

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

- The user exist
It can happen that a customer, which is already registered, it's interested on another property.
He fills the form again and submit.
At this point, we cannot add the user because it generates a "user exist" error, BUT we need anyway to create the new inquiry post and assign it to this user.
And even if the user it's not created, admin needs to know that a new inquiry post has been added.
But sadly the notification won't be sent because of the "user exist" error.
==>
Yes, because form is not going to submit due to duplicate user error returned by validation hook.

You can chose either to display error or you have to remove the validation hook and but removing validation hook will also not help as there will be no duplicate users.

You have to set a flow that if duplicate user found - you should redirect user to login page or try auto login and create a post and send notification using wp_mail() function as form is not going to submit, form notification is not going to trigger.

This is your custom flow and not how

#1974145

My issue is resolved now. Thank you!