Skip Navigation

[Gelöst] Send CRED form values to another 3rd party website in URL

Dieser Thread wurde gelöst. Hier ist eine Beschreibung des Problems und der Lösung.

Problem:
Is it possible to replace the values with data that has just been collected in our CRED form, to make the URL something like this:

http://smkphp.ukm.my/epayment/pay/get_url/?kod_epay=%5Bvalue from toolset field1]&amount=880.00&id_trans=[value from toolset field2]&bill_email=[value from toolset field3]&bill_desc=[value from toolset field4]

Solution:
Please use this code, and make sure to properly change field slug in the below code:

add_action('cred_submit_complete', 'my_success_action',10,2);
function my_success_action($post_id, $form_data)
{
    // I have corrected the ID
    if ($form_data['id']==7696)
   {
        $field1 = '';
    $field2 = ''; // I just changed it this way to make me understand better
     
    if(isset($_POST['wpcf-field1-slug']))
            {                                                        //      I added this opening bracket
        $field1 = $_POST['wpcf-field1-slug'];
        };                           //     I added this closing bracket and the semi-colon        
    if(isset($_POST['wpcf-field2-slug']))
            {
        $field2 = $_POST['wpcf-field2-slug'];
        }; 
     
        header('location: http://thedirectedpage.something/?field1='.$field1.'&field2='.$field2.'');     // I added the necessary apostrophe(s)  
 exit;
   }
}

Relevant Documentation:
https://toolset.com/documentation/programmer-reference/cred-api/#cred_submit_complete

This support ticket is created vor 7 Jahren, 1 Monat. 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.

Heute stehen keine Supporter zur Arbeit im Werkzeugsatz-Forum zur Verfügung. Sie können gern Tickets erstellen, die wir bearbeiten werden, sobald wir online sind. Vielen Dank für Ihr Verständnis.

Sun Mon Tue Wed Thu Fri Sat
- 12:00 – 17:00 12:00 – 17:00 12:00 – 17:00 12:00 – 17:00 12:00 – 17:00 -
- 18:00 – 21:00 18:00 – 21:00 18:00 – 21:00 18:00 – 21:00 18:00 – 21:00 -

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

Dieses Thema enthält 4 Antworten, hat 2 Stimmen.

Zuletzt aktualisiert von khairul-azmanA vor 7 Jahren, 1 Monat.

Assistiert von: Noman.

Author
Artikel
#578093

I want to send values from a form created using CRED, to a 3rd party page using URL.

My CRED form is in this page:
versteckter Link

In that form, the Submit button opens up a blank page that is set to redirect to the following URL of a 3rd party website:

versteckter Link A090906

Note that the URL contains values, eg. aQIF2017, that would be inserted into fields, eg. kod_epay, on that 3rd party page/form.

Is it possible to replace the values with data that has just been collected in our CRED form, to make the URL something like this:

versteckter Link from toolset field1]&amount=880.00&id_trans=[value from toolset field2]&bill_email=[value from toolset field3]&bill_desc=[value from toolset field4]

Or is there a different way of implementation? I have no control over the 3rd party page.

#578151

Noman
Supporter

Sprachen: Englisch (English )

Zeitzone: Asia/Karachi (GMT+05:00)

Hi Khairul,

Thank you for contacting Toolset support. For this you would need to use cred_submit_complete hook, check the usage example give here and inline comments:
https://toolset.com/documentation/programmer-reference/cred-api/#cred_submit_complete

If you want to get the field value, then you would use:

 $filed_value = $_POST['field_name']; 

We also have another client who had the similar issue and was also able to solve it:
https://toolset.com/forums/topic/pass-parameters-from-a-cred-form/

Other than that, this falls into pure Custom coding & custom development and it is out of support policy (https://toolset.com/toolset-support-policy/). So we recommend to contact Toolset recommended service providers to further discuss the custom approach. We have some recommended list of service providers here if you would like to take a look: https://toolset.com/consultant/

Thank you

#579240

Hi Noman

I have tried with the cred_submit_complete add_function. But I don't see any results.

Here's what I did:

- Following the link that you provided, I added the following code into my function.php file, just to try out with a simple redirecting command:

add_action('cred_submit_complete', 'my_success_action',10,2);
function my_success_action($post_id, $form_data)
{
    // if a specific form
    if ($form_data['id']==8142)
   {
        // user can overwrite everything here, eg redirection, messages displayed etc..
        // eg redirect regardless of form settings
        header('location: <em><u>versteckter Link</u></em>');
   }
}

- After filling up the form and submitting it, I was not taken to the redirected url, but rather back to a blank form.

The sample form created is here: versteckter Link

#579316

Noman
Supporter

Sprachen: Englisch (English )

Zeitzone: Asia/Karachi (GMT+05:00)

Hello Khairul,

I have updated the code please use this one, and make sure to properly change field slug in the below code:

add_action('cred_submit_complete', 'my_success_action',10,2);
function my_success_action($post_id, $form_data)
{
    // Please double check form id
    if ($form_data['id']==8142)
   {
        $field1 = $field2 = '';
		if(isset($_POST['wpcf-field1-slug']))
			$field1 = $_POST['wpcf-field1-slug']; // your field slug
		
		if(isset($_POST['wpcf-field2-slug']))	
			$field2 = $_POST['wpcf-field2-slug']; // your field slug
		
		header('location: <em><u>versteckter Link</u></em>'.$field1.'&field2='.$field2);
		exit;
   }
}

Thank you

#580945

Thanks. I used the code you provided but it didn't work. Then I modified the code and finally got it to work. The final code looks something like this:


add_action('cred_submit_complete', 'my_success_action',10,2);
function my_success_action($post_id, $form_data)
{
    // I have corrected the ID
    if ($form_data['id']==7696)
   {
        $field1 = '';
	$field2 = ''; // I just changed it this way to make me understand better
	
	if(isset($_POST['wpcf-field1-slug']))
            {                                                        //      I added this opening bracket
		$field1 = $_POST['wpcf-field1-slug'];
		};                           //     I added this closing bracket and the semi-colon        
	if(isset($_POST['wpcf-field2-slug']))
            {
		$field2 = $_POST['wpcf-field2-slug'];
		}; 
	
        header('location: <em><u>versteckter Link</u></em>'.$field1.'&field2='.$field2.'');     // I added the necessary apostrophe(s)  
 exit;
   }
}

Thank you very much for your assistance.