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.
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);
}
}
}
die('Validation error');
toreturn;
?update_post_meta()
call? And how are you calling thesave_metabox_details()
- is it hooked tosave_post
? But try an empty function..function save_metabox_details() {}
and see if the issue persists - if yes, then the problem is somewhere else..