@seriphyn Sorry for the late reply – just tested, but unfortunately is doesn’t work – for drafts or published pages… But I really appreciate you looking into this for me.
FYI – I queried the efficacy of your function with ACF support, and they said:
We’re currently looking at how we can implement validation in Gutenberg Blocks either by ourselves, or by contributing to Gutenberg as we agree we’ve had to wait too long to be able to implement this. There are many upcoming changes to Gutenberg’s saving system we hope will be hook into
The example code is too broad, and affects non-gutenberg content too, and happens too late in the chain than we’d expect, which is why we’re aiming to get a solution that works properly in the block editor – at the point the rest of page validation occurs.
@seriphyn Amazing thank you – but don’t go mad – being able to finally use required fields in GB blocks is good enough for me.
I am curious though – this looks like a pretty simple solution for a bug that’s been open 4 years – yet it only exists on this page, and hasn’t gained much attention. Am I missing something? I don’t understand why this hasn’t been added to core yet?
Also, can you explain what $acf = false;
does?
Thanks!
@seriphyn Just trying out your solution, but it doesn’t appear to be working… Do you know if this is still a viable solution with the latest ACF and WordPress? Thanks!
Edit – I’ve found it is working for Publish/Update – but not Save Draft. Is there a different hook available for saving drafts?
It seems this is the expected behaviour for ACF, so it does not validate drafts regardless. Thanks for posting a solution, much appreciated.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.