The Community forums are being phased out in favor of a new Slack group.
Add your email address below to get an invitation to join the community slack group
How to change status of post based on date
Hello, I want to create posts using Forms i need help to set the status of the post based on Date Field. For example if user set the future date then set the status of post as scheduled.
August 24, 2018 at 5:30 pm
Hi Muhammad,
This hook might be helpful - https://formidableforms.com/knowledgebase/frm_new_post/
August 29, 2018 at 9:04 am
having same issue... in the form for posting you can set a field for Post Date but it is not working for me
August 29, 2018 at 10:16 pm
Hi Offerscode,
Thanks for pointing that out. I just tested it. It works for me. I have a date field in my Form. Then in the "Create post" action, I specified my date field as "Post Date" and set "Post Status" to "Automatically publish".
When I submit an entry with the current date, the post is published immediately. When I submit with a future date, the post is scheduled for the given date.
I think this is what Muhammad was asking.
Offerscode, which part is not working for you?
August 30, 2018 at 9:36 am
So I just did a test, and it is scheduled for tomorrow so that seems to be working thanks.
August 30, 2018 at 10:01 pm
Glad that you made it work :)
September 2, 2018 at 7:00 am
So how do you create a scheduled date and time?
Looking at this. Does this seem right?
RE: https://formidableforms.com/knowledgebase/frm_new_post/#kb-examples
add_filter( 'frm_new_post', 'combine data and time into post_date', 10, 2 );
function change_my_post_date( $post, $args ) {
if ( $args['form']->id == 37 ) { //change 25 to the ID of your form
$datetime = $_POST['item_meta'][810] .' '. $_POST['item_meta']830];
//change each number (20, 21, 22, 23) to the ID of the field to insert
$post['post_date'] = $datetime;
}
return $post;
}
September 2, 2018 at 7:10 am
Also do I post this in the Snippet plugin or in the Customize HTML of the form? before /after?
September 2, 2018 at 10:42 pm
Which code?
If it is PHP, you could add to functions.php or Code Snippet plugin (my preference).
If it Javascript, then it goes to Customize HTML --> After Fields
September 3, 2018 at 4:06 am
So how do you create a scheduled date and time?
Looking at this. Does this seem right?
RE: https://formidableforms.com/knowledgebase/frm_new_post/#kb-examples
this still doesn't work...where do I add it? Code Snippets?
add_filter( 'frm_new_post', 'combine data and time into post_date', 10, 2 );
function change_my_post_date( $post, $args ) {
if ( $args['form']->id == 37 ) { //change 25 to the ID of your form
$datetime = $_POST['item_meta'][810] .' '. $_POST['item_meta']830];
//change each number (20, 21, 22, 23) to the ID of the field to insert
$post['post_date'] = $datetime;
}
return $post;
}
September 4, 2018 at 7:51 am
Got it to work thanks
see other support ticket I created.
September 4, 2018 at 8:09 am
see
http://community.formidableforms.com/help-desk/schedule-post-date-and-time/
Discussion closed.