acf-extended / ACF-Extended

🚀 All-in-one enhancement suite that improves WordPress & Advanced Custom Fields
https://www.acf-extended.com
238 stars 27 forks source link

Post not 'visible' until updated in edit post #123

Closed shannonschaerer closed 7 months ago

shannonschaerer commented 7 months ago

Describe the bug I am not sure if this is a bug or desired behavior.

To Reproduce Create form with action with post action 'save to post.' Display this in frontend, submit form.

Expected behavior Post ist created and available to loop.

WordPress & ACF WordPress version: latest ACF Pro version: latest ACF add-ons:

Add any other context about the problem here. As written upon form submission a post is create. However this post isn't 'usable' until the post is updated by pressing the 'Update' button in the edit post screen. By usable I mean that the post is output when queried in loop and that the permalink works. If this is desired behavior how I can I override in order to be able to use the post right after form submission. Thanks in advance.

acf-extended commented 7 months ago

Hello,

Thanks for the feedback!

ACFE Form use the native wp_insert_post() function (see documentation) behind the scene, when creating a post using the front-end form.

Which means that if you've set "Post Status = Default" in your Form UI: "Post Action", the post will be created as draft, since it is the default parameter of the wp_insert_post() function (see all default arguments).

Depending on how you display your posts on the front-end, it might be problematic since, most of the time, developers will want to display published posts only (and not draft posts) on the front-end.

Also note that publish is the default post_status argument of the WP_Query class (see documentation), which is used to loop posts on the front-end. So draft posts are excluded by default too.

I would recommend to either set your Post Action "Post Status = Published" in the Form UI, so your posts are published right when created or tweak your front-end WP_Query to allow draft post status, if you want to do so.

Hope it helps!

Have a nice day!

Regards.