Skip Navigation

[Resolved] Problem with feature image in Ads not copying to translated version

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

Problem:
How to duplicate the post in ALL configured WPML languages when post is created using CRED form.

Solution:
You can use CRED hook cred_save_data to duplicate the post in all language configured using WPML.

You can use WPML standard action "wpml_make_post_duplicates":

do_action( 'wpml_make_post_duplicates', $post_id );  

You can find proposed solution, in this case, with the following reply:
=> https://toolset.com/documentation/user-guides/using-toolset-with-beaver-builder/best-practices-creating-templates-beaver-builder/

Relevant Documentation:
https://wpml.org/wpml-hook/wpml_make_post_duplicates/

This support ticket is created 6 years, 8 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
- 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 10 replies, has 2 voices.

Last updated by PaulS4783 6 years, 8 months ago.

Assisted by: Minesh.

Author
Posts
#622585

I set the media translation within WPML as suggested.
https://toolset.com/forums/topic/free-ad-feature-image-doesnt-appear-on-translated-version/
It successfully copied the feature image to translations on EXISTING content.

However, when I tested again by adding a new FREE listing, it didn't copy the feature image.
hidden link
hidden link

Please advise what I should do.

#622943

Minesh
Supporter

Languages: English (English )

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

Hello. Thank you for contacting the Toolset support.

Well - I installed the classified's site and I'm able to reproduce this issue, I've report this issue for more information if this is expected behavior or bug.

I'll get in touch with you as soon as I know more.

#623230

Any update on this issue, yet?

#623276

Minesh
Supporter

Languages: English (English )

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

Well - there is no solution available for now but I've reported to next level support and they are investigating it. Please hold on for further updates.

#623303

Minesh
Supporter

Languages: English (English )

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

Well - to set featured image on translation you need to add following custom code to your current theme's functions.php file:

Could you please try to add following code and check if that help you to fix the issue.

add_action('cred_save_data', 'my_save_data_action',10,2);
function my_save_data_action($post_id, $form_data)
{
// if a specific form
if ($form_data['id']==99999)
{

// add it to saved post meta
$translated_id = apply_filters( 'wpml_object_id', $post_id, 'listing', true, 'es' );
$post_thumbnail_id = get_post_thumbnail_id( $post_id );
set_post_thumbnail( $translated_id, $post_thumbnail_id );

}
}

Where:
- Replace 99999 with your original CRED form Id.

#623525

Tried as you suggested.
But this didn't work.

add_action('cred_save_data', 'my_save_data_action',10,2);
function my_save_data_action($post_id, $form_data)
{
  // if a specific form
  if ($form_data['id']==6350)
  {
  // add it to saved post meta
  $translated_id = apply_filters( 'wpml_object_id', $post_id, 'listing', true, 'es' );
  $post_thumbnail_id = get_post_thumbnail_id( $post_id );
  set_post_thumbnail( $translated_id, $post_thumbnail_id );
 
  }
}
#623544

There are ALSO two different but perhaps related problem.

1. When I try to post a PREMIUM AD using may PayPal Sandbox account, the order is held as pending.
I need to go into the WooCommerce Orders list and update the order status from ON HOLD to COMPLETE.
How can I get WooCommerce to automatically save the order as COMPLETE? (Virtual/Downloadable are both checked)?

2. However, once I change the order status to COMPLETE, the site goes ahead and creates the translated version:
a) It DOES copy the feature image BUT
b) It DOESNT use the custom post template. It uses the standard "post" template.
e.g.
hidden link

Please advise.

#623557

Minesh
Supporter

Languages: English (English )

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

Well - we will deal here with the featured image issue and please kindly open a new ticket with your each new questions. That will help other users searching on the forum. Thank you for understanding.

Regarding featured image issue: I need access details in order to check whats going wrong there.

*** 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.

#624254

Minesh
Supporter

Languages: English (English )

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

Yes - I need FTP access details as its needed to edit your functions.php file. Could you please share it.

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

#624610

Minesh
Supporter

Languages: English (English )

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

Ok - finally. I've added following code to your current theme's functions.php file:

add_action('cred_save_data', 'my_save_data_action',10,2);
function my_save_data_action($post_id, $form_data){
  // if a specific form
  if ($form_data['id']==6350){
	  
	   do_action( 'wpml_make_post_duplicates', $post_id );            
  }
}

This will make entire post duplicate to your another language so you will have to adjust your content accordingly.

#624803

OK. Thank you. That appears to work now.