Skip Navigation

[Resolved] How to create a post title that has identical value as one of the fields

This support ticket is created 8 years, 4 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.

No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.

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

Supporter timezone: Africa/Cairo (GMT+02:00)

This topic contains 2 replies, has 2 voices.

Last updated by Anthony 8 years, 3 months ago.

Assisted by: Ahmed Hussein.

Author
Posts
#397821

I am trying to: create a post title that has the same value as one of the CPT fields without making the user input the exact same data twice

I visited this URL: several

I expected to see: didn't know what I would see

Instead, I got: some things that were pretty close, but were no help.

<div class="cred-field cred-field-post_title">
<label class="cred-label">Post Name</label>
  [cred_field field='post_title' post='request' value='' urlparam='']
</div>

<div class="cred-field cred-field-some-other-field">
    <label class="cred-label">Some Other Field</label>
    [cred_field field='some-other-field' post='request' value='' urlparam='']
</div>

Like I said, I need to use the value from one of the fields in a content creation form for the post name value. I tried this:

 var theForm = jQuery(".cred-form");
  
  theForm.submit(function (e) {
    e.preventDefault();
    
    jQuery("#post_title").val(jQuery("input[name='wpcf-some-other-field']").val());
    this.submit();
  });

But I couldn't get it to work by adding it to the Javascript section of the form generator, so no joy.

Is there a way to do this in the cred code? If it were being passed I could have it, but it is being input at the time the form is being submitted to Toolkit. Not seeing it - tips and tricks welcome.

Thanks -

#397962

Hi, Thanks for contacting Toolset support forums.

I've been able to achieve what you want using this code snippet:

var mainField = jQuery("input[name='wpcf-main-field']");
  
 jQuery(mainField).on("change", function (e) {
    jQuery("input[name='wpcf-some-other-field']").val(jQuery(this).val());
 });

Utilizing the jQuery change event instead of the submit, you can also change that for keyup or keydown or adjust it as you need.

If you need more professional help you may contact one of our certified partners, and they'll be more than happy to help you do any custom coding you may need. https://toolset.com/consultant/

Please let me know if that solves your problem.

Cheers!

#398170

Hey thanks,

I replaced the CRED input with a regular hidden form input and that didn't work either. However, I subsequently deleted the hidden input that I had added and then put the original CRED input back. After that, I used CSS ("hidden") to hide that cred field and the form processed as desired! So, for anybody else reading this, just hide the CRED field that should be populated with the duplicate value (using CSS) and make the appropriate changes to Ahmed's jQuery snippet and you should be good to go.

Thanks again Ahmed.

This ticket is now closed. If you're a Toolset client and need related help, please open a new support ticket.