Home Forums General Issues Advanced Custom Fields conflicting with custom plugin when saving custom field


Advanced Custom Fields conflicting with custom plugin when saving custom field

  • I’m writing a plugin for the practice and running into an issue where another plugin, Advanced Custom Fields is conflicting with my code. I have created a custom post type with it’s own custom field. My save method works and the custom field data is saved if I disable ACF, however I am getting a validation error that I think comes from the acf plugin when trying to save/publish with the plugin active. See pic for the error message.

    So I guess my question is, do I need to check if that plugin is active and use it’s functions to handle this and if not do it the normal way, or am I doing something else wrong? Does every plugin that saves custom field data have to check if this plugin is active and handle it accordingly? That just doesn’t seem right to me but this is my first time writing a plugin.

    The validation error:

    validation error

    Here is my save method:

    public function save_metabox_details() {
            global $post;
            if(current_user_can('editor') || current_user_can('administrator') && isset($_POST['ipmyskills_nonce'])) {
                $nonce = $_POST['ipmyskills_nonce'];
                if( $nonce && !check_admin_referer( basename(__FILE__), 'ipmyskills_nonce' )) {
                    die('Validation error');
                if (isset($_POST['ipmyskills_input'])) {
                    $sanitized_value = esc_html( sanitize_text_field( $_POST['ipmyskills_input'] ) );
                    update_post_meta($post->ID, 'ipmyskills_input', $sanitized_value);

    This method gets called in my class’s constructor:

    function __construct()
            add_action('init', array($this, 'ip_myskills_register_post_type'));
            add_action('load-post.php', array($this, 'init_metabox'));
            add_action('load-post-new.php', array($this, 'init_metabox'));
        public function init_metabox() {
            add_action('add_meta_boxes', array($this, 'skillsmetabox_init'));
            add_action('save_post', array($this, 'save_metabox_details'));
  • Not really enough information.

    Are there ACF fields that appear on the post type that you’re editing when ACF is active?

  • LOL! I completely forgot that I originally was building this with acf into the theme before deciding to try and build it as a plugin. Had a custom field group assigned to the post type. Deleted the field group and everything works now. Thank you 🙂

  • I actually build plugins with ACF and use ACF options pages for plugin configuration settings. Saves a boatload of work building my own forms and save filters.

Viewing 5 posts - 1 through 5 (of 5 total)

The topic ‘Advanced Custom Fields conflicting with custom plugin when saving custom field’ is closed to new replies.