16 May 2016

Advanced Custom Fields plugin proper multilanguage site redirection after posts save

Based on ACF acf/save_post action hook. Some of our

16 May 2016

Based on ACF acf/save_post action hook.

Some of our recent projects on WordPress were based on wonderful Advanced Custom Fields plugin.

It’s all good except some pretty common but not out-of-the-box cases. We say about Multilingual sites.

When you have exposed posts saving form on frontend, and customer saves new content, the post is redirected to your site’s base language URL.

F.e., you have created a form like this:

NB: we use ACF Pro version, so our codes are based on ACF Pro 5 version.

If you have enabled Multisiting with some plugins (we use WPML in most cased) then you desired URL will be http://www.example.com/blog/[language_code]/post-title/. But on practice customer is redirected to http://www.example.com/blog/post-title/ that creates bad user experience, especially if you don’t have language switcher or have inexperienced customer on site.

To fix this issue just use this simple snippet in your theme’s functions.php file or in some plugin that is used for ACF frontend form creation:

That’s easy!

Now you have proper redirects after posts saving with frontend forms created by ACF plugin.

 

 

Leave a comment
More Posts
Comments
Comment