Skip Navigation

[Resolved] Cred Form on Views Content Template

This support ticket is created 7 years, 11 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 7 replies, has 3 voices.

Last updated by Caridad 7 years, 11 months ago.

Assigned support staff: Minesh.

Author
Posts
#271826

I have a Content Template that I am going to embed a [cred_form form="contact us"]

What I would like to do is somehow put some shortcode or something in there so that whenever someone fills out that contact form a hidden field is filled in that contains the post they were viewing. It could be the URL, the page title, another field from the page. I don't care. Just has to be something that makes it easy to know where they came from if they don't mention it in their contact request.

I was thinking you might have something like:

[cred_form form="contact us" refer="[wpv-post-url]"]

Thanks!

#272003

Waqas
Supporter

Languages: English (English )

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

This is Waqas here, on behalf of Ms. Caridad. She's on vacation and will back next week.

Meanwhile, you can try the following solution by adding a Generic Hidden Field to your form, as below:

[cred_generic_field field="referrer" type="hidden" class="" urlparam=""]
{
"required":0,
"validate_format":0,
"persist":0,
"default":"My Page Title"
}
[/cred_generic_field]

Please notice the "default" parameter in above field definition. You can set that to anything you want. I hope this helps you resolve the issue.

However, she will follow up with you, as she returns. Thank you for your cooperation and patience.

#272006

Hi Waqas,

I appreciate you stepping in for Caridad but I don't think that will work. If I enter "My Page Title" in there, then it will always have the same text show up in the field. I need this entry to be dynamic. I'm placing this contact form in different places throughout the site and on dynamically generated views.

Larry

#272377

You will need some code to resolve this.

For example, you can use a custom shortcode to display the referer field.

add_shortcode('referer', 'referer_shortcode');
function referer_shortcode($atts) {
  return esc_url( $_SERVER['HTTP_REFERER'] );
}

Then you can use this shortcode in your CRED for to give a default value.
You can use a custom field to store the referer value and hide it with CSS.

[cred_field field="referer" post="post" value="[referer]"]

Please let me know if you are satisfied with my reply and any other questions you may have.

Regards,
Caridad

#272895

Hi Caridad, welcome back! I hope you had a great vacation.

I added the function you provided along with the custom field 'referer' to my form. However, it's not adding the referring information on submit. Am I doing something wrong?

#273566

Do you have created a single line custom field called 'referer' in your custom post type?

#273660

Did I need to? You're instructions didn't include that.

#274101

I'm sorry that I wasn't very clear, but I meant to say it in this sentence:

"You can use a custom field to store the referer value and hide it with CSS."

Regards
Caridad