Skip Navigation

[Resolved] find Post id on custom save

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

Last updated by franciscos-9 5 years ago.

Assisted by: Minesh.

Author
Posts
#1392943

I am trying to:
What is the goal , to insert posts of custom date fields . tried to use cred_save_data() function to add all dates that start on 'datepicker-field start date' and end on 'datepicker field end date', start-date is saved. do i need to put post_id.

for( $i = 1; $i < $count; $i++ ) {
$nex_date = strtotime("+$i days",strtotime($start_date));
add_post_meta($post_id, 'wpcf-start-date', $nex_date);

Link to a page where the issue can be seen:
hidden link
I expected to see:
it does not look like saved dates was succesful
Instead, I got:
only 1 start-date is saved.

#1393115

Hello,

I have tired the URL you mentioned above, but don't find any Toolset form in it.
Please elaborate the question with more details:
How do you setup the custom date fields: start-date and end-date?
Is start-date field a multiple instance field?
Are you going to add multiple instance into start-date field, values are date between start-date and end-date?

The post ID is in cred_save_date action hook as a parameter, see our document:
https://toolset.com/documentation/programmer-reference/cred-api/#cred_save_data

#1393141

I have changed your reply to private post, it is not safe to share the credentials publicly.

Do you need setup an example codes in your website?
Where can I edit your custom PHP codes?

#1393161

Hi,
yes sample codes. code is in functions.php . where do i send ftp login.

i created a page to edit the code:hidden link

#1393187

OK, I have enabled the private message box, please provide your website FTP access in it, thanks

#1393943

Thanks for the details, the cred_save_data is an action hook, it is not shortcode, I have added below codes in your theme file "functions.php":

add_action('cred_save_data', function($post_id, $form_data){
	// if a specific form
	if ($form_data['id'] == 1292){
		$start_date = get_post_meta($post_id, 'wpcf-start-date', true); 
		$end_date = get_post_meta($post_id, 'wpcf-end-date', true);
		
		for( $new_date = $start_date + (60*60*24); $new_date < $end_date; $new_date += (60*60*24)){
			add_post_meta($post_id, 'wpcf-start-date', $new_date); 
		}
	}
}, 10, 2);

Please test again, check if it is what you want.

More help:
https://toolset.com/documentation/programmer-reference/cred-api/#cred_save_data

#1397543

Hi,
this what i want. my issue is resolved. thank you

#1397697

Minesh
Supporter

Languages: English (English )

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

Luo is on vacation. This is Minesh here and I'll take care of this ticket in Luo's absence. Hope this is OK.

Please feel free to close this ticket and open a new ticket with your every new question you may have.

#1397755

My issue is resolved now. Thank you!