Navigation überspringen

[Gelöst] Copy content / but clear some fields

This support ticket is created vor 6 Jahren, 11 Monaten. 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)

Dieses Thema enthält 8 Antworten, hat 3 Stimmen.

Zuletzt aktualisiert von Daniel vor 6 Jahren, 11 Monaten.

Assistiert von: Minesh.

Author
Artikel
#609552

Hello,

I successfully build a form to clone my content (https://toolset.com/forums/topic/create-copy-post-link-in-logged-in-user-view/ ).

The question is, if the code can be changed that some fields could be cleared (for example wpv-name and wpv-city).

Thanks, Daniel

#609627

Minesh
Supporter

Sprachen: Englisch (English )

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

Hello. Thank you for contacting the Toolset support.

As I understand - you are asking that if you remove the custom field wpv-name and wpv-city, is there any effect on the code that Christian shared - is that correct? If no: could you please explain your question with brief test case example.

#609978

Hello MInesh,

the idea is to clone the data, but to clear the content of some special fields. In my example I have a database with cd reviews. If the next cd comes I only need some data, but not song-1. song-2, song-3 and the album name.

It would be great, if I could clear them while cloning the rest?

Best, Daniel

Please excuse my english 😉

#610061

Dear Daniel,

Minesh is on the holiday, he is not available currently and you will get the answer when he is back on Monday.

#610939

Minesh
Supporter

Sprachen: Englisch (English )

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

When you say clone data - what is the exact process of clone data and which fields you would like to remove?

As when you clone the data - eventually it will create a new post ID (if I'm not wrong), could you please share test case example and your exact required output.

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

#612746

Minesh
Supporter

Sprachen: Englisch (English )

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

Well - where I can find the link t"clone" - from where I can perform the "clone" action?

#612996

it's here: versteckter Link

#613680

Minesh
Supporter

Sprachen: Englisch (English )

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

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

add_action('cred_save_data_17859', 'func_clone_duplicate_post', 10, 2);
function func_clone_duplicate_post($post_id, $form_data) {
    // get data of original post
    update_post_meta($post_id,'wpcf-album','');
	update_post_meta($post_id,'wpcf-jahr','');
	update_post_meta($post_id,'wpcf-beitragsslink','');
	update_post_meta($post_id,'wpcf-song-1','');
	update_post_meta($post_id,'wpcf-song-2','');
	update_post_meta($post_id,'wpcf-song-3','');
	
}

The above code is responsible to reset the said field value to empty. Could you please confirm that this works for you.

#613878

Yes Minesh, that does exactly what I wanted. Thanks a lot!