Skip Navigation

[Résolu] Cred makes 'auto draft' from [wpv-post-id] after upgrade cred 1.3

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.

Marqué : 

This topic contains 14 réponses, has 4 voix.

Last updated by Joff Il y a 7 années.

Assigned support staff: Adriano.

Auteur
Publications
#238494
productwithcredform1.3.JPG
productwithcredform.JPG

On my local computer I upgraded the new Cred version and now I get 'auto draft' instead of the post-id or post-title (see productwithcredform1.3.jpg).
I have custom posttypes: product, bedrijf (=company) and bedrijfsproducten(to make many-to-many relation possible). You can see 'bedrijven' as children of the product. In my product content I have a childform to add new 'bedrijfsproducten'. In the old version I could us this [cred_field field="_wpcf_belongs_product_id" value="[wpv-post-id]"]. This worked perfect, but not anymore in the new version. I use the [wpv-post-id], so my users don't have to choose the product and I use it in javascript to make a title for my 'bedrijfsproduct' as you can see in the other image.

Any idea? I tried [wpv-post-id id = '$parent'] , doesn't work either. I only get 'auto draft'.

#238595

Ana
Supporter

I would suggest you use the following

 [cred_field field="_wpcf_belongs_product_id" value="[wpv-post-id id = '$product']"]

essentially replacing the $parent with the correct slug for the parent you want to get the id from.

Could you paste here the form content for the CRED form your using and also the cusotm javascript you have for it, so I can better understand what you want to accomplish.

Thanks

#238656

Hi Ana,

Thank you for your reply. I already tried that, but it doesn't help. And again it all works nice (without the id='$product' in version 1.2.6 of CRED.
Here is my code with the $product:

[credform class="cred-form cred-keep-original"]

	[cred_field field="form_messages" value=""]

	<div class="cred-group cred-group-Bedrijfsrol">
		<div class="cred-field cred-field-bedrijfsrol">
			<div class="cred-label">Bedrijfsrol</div>
			[cred_field field="bedrijfsrol" post="bedrijfsproduct" value="" urlparam="" required="true" select_text="Wat doet het bedrijf" validate_text="Er moet een rol geselecteerd worden"]
		</div>
	</div>

	<div class="cred-group cred-group-parents" >
      <div class="cred-field cred-field-_wpcf_belongs_product_id"  >
			<div class="cred-label">Product</div>
			[cred_field field="_wpcf_belongs_product_id" value="[wpv-post-id id='$product']"]
		</div>
      	
		<div class="cred-field cred-field-_wpcf_belongs_bedrijf_id">
			<div class="cred-label">Bedrijf</div>
			 [cred_field field="_wpcf_belongs_bedrijf_id" value="" order="title" ordering="asc" required="true" select_text="- Selecteer bedrijf -" validate_text="Er moet een bedrijf geselecteerd worden"]
		</div>
		
	</div>
<div id="product" >[wpv-post-title id='$product']</div>
    <div class="cred-field" style="display:none" >
    [cred_field field="post_title" post="bedrijfsproduct" value="" urlparam="" ]
    </div>
	[cred_field field="form_submit" value="Voeg toe" urlparam=""]

[/credform]

and the javascript:

jQuery( function( $ ) {
  
$('select[name=_wpcf_belongs_bedrijf_id]').change(titel);
  
function titel() {
		
		var a = $('select[name=_wpcf_belongs_bedrijf_id] option:selected').text();
  		var b = $("#product").text();
  		var total = a + '-'+ b;
        $('input[name=post_title]').val(total);
   
}
  
} );
#238921

Ana
Supporter

I've managed to replicate what you have described and I'm reporting it has a bug to the development team so that they can check on it.
Thanks for your patience.

One extra note on why the 'Auto draft' as title is being displayed. This is because the CRED from is creating a new post and at this time is not yet created so is displaying the default title for the post.
It is not displaying the parent title there because no parent was yet saved to the post that is being created, so the meta information for parent of the post doesn't exists yet.

#238934

Thank you Ana for your reply. Sorry, but I don't agree with your last note. The title I use is from the product that already exists. It is the parent post with the CRED form included. So it seems to make sense to use id="$parent", or id="$product". But in the 2.6 CRED version I don't need to do that. Just [wpv-post-id] or [wpv-post-title] gives me the title or id from the parent post. I will wait with the install of CRED 1.3 until your development team found the solution.

#240376

Ana is not available to handle this issue anymore, I will. The CRED 1.3.1 should solves this issues, can you please confirm that?

#240381

Nice Adriano, you guys ar so helpfull!
But unfortunately the problem is not solved. I still get 'Auto Draft' instead of the post title when I use [wpv-post-title]

#240387

Ok, I 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. You will find the needed fields for this below the comment area when you log in to leave your next reply. The information you will enter is private which means only you and I can see and have access to it.

#240419

You've got the login from the testsite. Choose for example Producten, Aardbeien. When you are logged in you will see the childform to add 'bedrijfsproducten'.
Choose a 'bedrijf' (selecteer bedrijf). You will get the 'bedrijfsproduct' with Auto Draft. The Auto Draft should be 'Aardbeien". The CRED-form used here is: 'Bedrijven bij product'.
I use the hidden field: <div id="product" style="display:none">[wpv-post-title]</div> in javascript to give a title to my 'Bedrijfsproduct'. It worked well in the old CRED version.

I hope you will manage to find your way in this only dutch site. Success!

#241454

Hi Adriano, is something wrong? I am still waiting for your reply.

#241516

My apologies the long delay on this. I'm trying to find a solution by some local tests. I'm still getting "auto draft". I will let you know as soon as I figure how to resolve that.

#241518

Ok, thank you. Guess I have to be patient 🙂

#242277

My apologies the long delay. The only solution I can thing is using CRED API: https://toolset.com/documentation/user-guides/cred-api/#csd

You should use a hook, like cred_save_data, then edit the title after CRED create that. Does it makes sense?

#242477

Sorry Adriano, but your solution doesn't make sense. I need the title and the id of the parent and not of the credform it self. I set the title with javascript,but the saving is not the problem.

But when I was thinking about this I found a solution myself. I now use javascript to get the title and id of the parent. And now it works well as it did with [wpv-post-title], and [wpv-post-id] in the former CRED version.

jQuery( function( $ ) {
  
$('select[name=_wpcf_belongs_product_id]').change(titel);
  
function titlel() {
		var a = $(".entry-title").text(); 
		var b =  $('select[name=_wpcf_belongs_product_id] option:selected').text();  
  		var c = $("#bedrijfid").text(); 	
  		var titlel = a + '-'+ b;
        $('select[name=_wpcf_belongs_bedrijf_id]').val(c);
        $('input[name=post_title]').val(title);
   
}
  
} );
#320327

A bit late to the party but I was just wanting to pull the parent title into my form. I have the form shortcode within the page.

I slightly modified Louy's code at https://toolset.com/forums/topic/auto-fill-parent-field-in-cred-form/page/2/#post-320324 to suit my needs

//Shortcode to get current page as parent (for CRED form relationships)
add_shortcode('current-parent-title', 'current_parent_id_func');
function current_parent_id_func($atts, $content){
    $queried_object = get_queried_object();
    $title = get_the_title($queried_object);
    return $title;
}

Now the [current-parent-title] shortcode provides the parent title. As get_queried_object returns the current post, this could be modified to extract any post data really.