Skip to content

Conversation

@sbassah
Copy link
Contributor

@sbassah sbassah commented Feb 1, 2023

Context

https://www.notion.so/gravitywiz/Update-How-to-Update-Posts-Update-Posts-Date-and-Time-2c6804a35da642eba85b49ffaec5b2aa

Added support to set the post date with a single value like 11 which can be a Date or Time field ID. If it is a Date field, the time is set to midnight. If it is a Time field, the date is set to the current date.

new GW_Update_Posts( array(
'form_id' => 123,
'post_id' => 1,
'post_date' => 11, // This can be either the Date or Time field ID.
) );

It also supports setting the Post date with an array of Date and Time field IDs like so

new GW_Update_Posts( array(
'form_id' => 123,
'post_id' => 1,
'post_date' => array(
'date' => 11,
'time' => 12,
),
) );

@sbassah sbassah changed the title Samuel/add/update post date and time Update post date with either a date or time or both. Feb 1, 2023
@sbassah sbassah requested a review from spivurno February 1, 2023 08:50
Copy link
Contributor

@spivurno spivurno left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sbassah Great work, man! I moved the logic to its own function since it was getting beefy and tweaked it slightly for clarity. Could you test this one more time on your end and make sure all the scenarios are still working?

Exciting to see you producing code of this quality!

@sbassah
Copy link
Contributor Author

sbassah commented Feb 1, 2023

@spivurno It works when the array parameter is used, but it throws a fatal error with the message below when the integer parameter is used.

Fatal error: Uncaught Error: Cannot use a scalar value as an array in...

@spivurno spivurno merged commit 97b1ba1 into master Feb 2, 2023
@spivurno spivurno deleted the samuel/add/update-post-date-and-time branch February 2, 2023 18:26
spivurno added a commit that referenced this pull request Oct 7, 2023
* `gw-update-posts.php`: Added support to update post date and time.

* `gw-update-posts.php`: Added support to update post date gmt.

* `gw-update-posts.php`: Made requested changes.

* `gw-update-posts.php`: Added support to set post date.

* ~ Functionality was getting beefy so I split it into its own function and tweaked slightly.

* ~ Fixed notice.

---------

Co-authored-by: David Smith <david@gravitywiz.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants