I am trying to use the Advanced Custom Fields acf_form()
function inside of an INLINE type Magnific Popup to edit and create posts on a WordPress site. It’s a work in progress; here’s the link. You can log in with username test
and password ukQfQ7zx7akPXH
.
The WordPress content editor works, it’s just that I’m not able to click inside the “Visual” tab, which kind of defeats the purpose of a WYSIWYG.
I’ve made sure that each of the ACF forms has a unique id
attribute. So, I’m guessing the problem is some sort of conflict with TinyMCE and Magnific Popup. However, no console errors are appearing in Chrome.
Has anyone encountered anything like this before?
UPDATE
Here’s the new code:
function cb_new_post_popup() { ?>
<div id="new-post-popup"
class="update-popup mfp-hide">
<h3>New Post</h3>
<?php
$current_user = wp_get_current_user();
$args = array('fields' => array('field_54134c496ff9d', 'field_541877c6025b3'),
'form_attributes' => array('id' => 'acf-form-new_post'),
'post_title' => true,
'post_content' => true,
'post_id' => 'new_post',
'new_post' => array('post_status' => 'publish'),
'return' => '%post_url%');
acf_form($args);
?>
<script>
jQuery(function($) {
acf.do_action('append', $('#new-post-popup'));
});
</script>
</div>
<?php }
SECOND UPDATE
I’ve also tried adding this to the magnificPopup
function in the JS:
callbacks: {
open: function() {
console.log('Popup is opened');
acf.do_action('append', $(this));
},
close: function() {
tinymce.activeEditor.save();
}
// e.t.c.
}
I think the issue is caused by ACF’s JS not firing an action when your popup is loaded. This action is used to setup all the field’s JS.
You can manually fire the action like so:
acf.do_action('append', $('#popup_id'))
Please swap out #popup_id with a selector for your popup, and add this code within an inline script tag in your popup’s content HTML.
Cheers
E