Skip Navigation

[Resolved] URL parameter value is not set for the field inside a CRED form

This thread is resolved. Here is a description of the problem and solution.

Problem:

Use CRED filter hook "cred_success_redirect" to pass URL parameters.

Solution:

See the example codes here:

https://toolset.com/forums/topic/url-parameter-value-is-not-set-for-the-field-inside-a-cred-form/#post-683464

Relevant Documentation:

https://toolset.com/documentation/programmer-reference/cred-api/#cred_success_redirect

This support ticket is created 6 years, 7 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/Hong_Kong (GMT+08:00)

This topic contains 12 replies, has 3 voices.

Last updated by Luo Yang 6 years, 7 months ago.

Assisted by: Luo Yang.

Author
Posts
#654950

I am trying to: apply the fix https://toolset.com/errata/url-parameter-value-is-not-set-for-the-field-inside-a-cred-form/ to my site so i can use urlparm in CRED form

please note i'm using the Beta version of Types, CRED and Views

Link to a page where the issue can be seen: hidden link

I expected to see: The CRED form on the page

Instead, I got: page with no CRED form

when i replace the "translate_field_factory.php" file as instructed the form is not displaying on the page. when i revert the original "translate_field_factory.php" the form display with no problem.

the issue is two folds

1. when trying to apply the fix the form don't show on the page
2. urlparm don't show in the url after submitting the form

i try to set the CRED form to include a urlparam with a few of the fields the user submit in the CRED form. however the urlparam is empty when i submit the form. so I'm not sure what to type in the urlparam=''

[cred_field field='form_submit' value='Match' urlparam='' class='btn btn-primary btn-lg' output='bootstrap']

the user fill the field my budget with a number. i want to take this number and pass it in a urlparam when i redirect the to a pge once the user submit the form.

the budget field in CRED look like this:

<div class="form-group">
		<label>[wpml-string context='cred-form-My Rider Profile-65' name='My Budget is']My Budget is[/wpml-string]</label>
		[cred_field field='my-budget-is' value='' urlparam='' class='form-control' output='bootstrap']
	</div>

i would like to take the value of the the field "my-budget-is" and have the redirect urlparm something like (lets say the value is 2500)

<em><u>hidden link</u></em>

i tried:

urlparam='pr=[types field="my-budget-is" format="FIELD_VALUE"][/types]'

and

urlparam='pr="2500"'

with no success

i used

add_filter('cred_success_redirect', 'custom_redirect',10,3);
function custom_redirect($url, $post_id, $form_data)
{
    if ($form_data['id']==65)
        return  $_SERVER['HTTP_REFERER'];
    return $url;
}

with no success

Please advice,
thanks,

David

#655270

Minesh
Supporter

Languages: English (English )

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

Hello. Thank you for contacting the Toolset support.

Well - Is there any specific reason that you are using Beta version of Toolset plugins - If no - we always recommend to use latest stable released version of Toolset plugins.

Additionally - the following URL shows that issue is fixed with CRED version 1.9 and current stable CRED version is 1.9.5.
=> https://toolset.com/errata/url-parameter-value-is-not-set-for-the-field-inside-a-cred-form/

Could you please try to check with latest stable Toolset plugins?

Also - I see you bit misunderstood the usage of URL param here. "urlparam" is used to set the value for fields when you load the CRED form.

In your case:

add_filter('cred_success_redirect', 'custom_redirect',10,3);
function custom_redirect($url, $post_id, $form_data)
{
    if ($form_data['id']==65){
       $budget =   get_post_meta($post_id,'wpcf-my-budget-is',true);
        return  YOUR-FULL-URL."/?pr=".$budget;
   }
    return $url;
}

Where:
- Replace YOUR-FULL-URL with your actual redirection URL.

Could you please try and let me know if it help you to resolve your issue.

#660101

Thanks Minesh,

I have try a few things to solve this with the code in the following configuration with no success:

1. CRED beta
2. CRED beta with Patch from https://toolset.com/errata/url-parameter-value-is-not-set-for-the-field-inside-a-cred-form
3. CRED 1.95
4. CRED 1.95 with the above patch

I noticed that when i revert to the CRED 1.9.5 the form field does not show on the page.
i have tried to create a new form but get the same results
you can see the issue at hidden link

I might have misunderstand the urlparm usage.
My understanding is that I can redirect a user to a page after the post is submitted and include urlparm in the url by defining urlparm in the shortcode:

[cred_field field='form_submit' value='Match' urlparam='' class='btn btn-primary btn-lg' output='bootstrap']

Please advice,

David

#670512

Minesh
Supporter

Languages: English (English )

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

Could you please share access details:

*** Please make a FULL BACKUP of your database and website.***
I would also eventually need to request temporary access (WP-Admin and FTP) to your site. Preferably to a test site where the problem has been replicated if possible in order to be of better help and check if some configurations might need to be changed.

I would additionally need your permission to de- and re-activate Plugins and the Theme, and to change configurations on the site. This is also a reason the backup is really important. If you agree to this, please use the form fields I have enabled below to provide temporary access details (wp-admin and FTP).

I have set the next reply to private which means only you and I have access to it.

#677271

Minesh
Supporter

Languages: English (English )

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

well - the FTP access details you shared is not working. Could you please send me working FTP access details.

Additionally - I checked on the staging site - I see CRED form is added here:
=> hidden link

I see no value displayed on above page - could you please also confirm the exact flow what values should be displayed where and on which URL you want to redirect the CRED form.

I have set the next reply to private which means only you and I have access to it.

#679171

Hi Minesh,

Toolset private response for the FTP information requires a folder in the response but in reality I don't have specific folder to point you too.
Instead of clicking the FTP link copy it and just remove the extension as i instructed in the previews private response "!!! Please remove the folder name "Remove_this" from the FTP link to access the ftp."

The CRED form have all the CPT Field on the page:
Rider first name
Rider last name
Age group
User riding goal
I want to ride
My technical riding skill is
My fitness level is
My Budget is
Weight
Height
Sex
Years of riding
The area i live in is

The page to redirect the user after the form is hidden link
Where urlparm can be added in the redirect link like this hidden link urlparm]

Thanks,

David

#683464

Hello,

Minesh isn't available, I will take care of this ticket.

The FTP access you provided is not valid for me too.

I have done below modifications in your website:
1) Create a CRED form for creating new "Riders Profiles" post:
hidden link
To simplify the problem, there are only two field in it: post title + "My Budget is" field

2) display above CRED form in page:
hidden link

3) Install the code Snippet plugin in your website, and add PHP codes here:
hidden link

add_filter('cred_success_redirect', 'custom_redirect_func', 99, 3);
function custom_redirect_func($url, $post_id, $form_data)
{
    if ($form_data['id']==112) // this is CRED form ID
	{
		
		$budget = get_post_meta($post_id, 'wpcf-my-budget-is', true);
		$url .= "?pr=" . $budget;
		// here add more URL parameters
	}
    return $url;
}

You can test the result here:
hidden link

This is only an example, you will need to setup the CRED form, add custom fields and codes in the PHP codes.

#687433

Hi Luo,

this is great and its working as expected.
I concluded that the functionality plugin was the issue and removed it. I use the code spinets plugin instead as you suggested.

a question:
what does the "urlparm" in the Cred submit button is for? I couldn't find much documentation about it. and i wonder how i can I use it as follow:

[cred_field field='form_submit' value='Match' urlparam='pr=[types field="my-budget-is" format="FIELD_VALUE"][/types]' class='btn btn-primary btn-lg' output='bootstrap']

as for FPT access - did you remove the folder name from the URL as instructed before?

Thanks,

David

#689820

Here is the document:
https://toolset.com/documentation/user-guides/cred-shortcodes/#cred_field

urlparam. Optional. A URL parameter to set default value. For example, a URL with the additional parameter ?some_param=some_value will set the some_value value to some_param.

For example, you are using CRED shortcode
[cred_field field="mobile" post="agent" value="" urlparam="pr"]

You can pass URL"pr" parameter to CRED form, like this:
hidden link

#692480

this is clear,
my question is more around the urlparm in the "submit button" of the form. not the cred_field in the form.

Thanks,

David

#695200

The submit button of CRED form does not pass/accept special URL parameter, it works for user clicking and submitting the CRED form. Hope it is clear.

#695360

ok,
thanks i got it now.
for some reason the fact the urlparm is in the submit button confused me to think it can pass into a query string.
its clear now.

David

#695413

You are welcome