I'm trying to remove a custom metabox that I've created for my plugin using PHP code. It should be removed from all the posts on click of a button. Here is my code:
<?php
if(isset($_REQUEST['submit_btn']))
{
function remove_custom_metabox()
{
remove_meta_box( 'my-meta-box-id' , 'post' , 'normal' );
}
add_action( 'add_meta_boxes', 'remove_custom_metabox');
}
?>
Why is it not working? And is there any way to do this for multi-post custom meta-box as well? Thanks!
EDIT 1: Just to get more clear idea of what I'm doing, here is how I'm creating the custom meta-box in the main plugin file:
function cd_meta_box_add()
{
add_meta_box(
'my-meta-box-id', //id
'Contributors', //title
'cd_meta_box_cb', //callback
'post', //post type
'normal', //position
'high' //priority
);
}
add_action('add_meta_boxes', 'cd_meta_box_add');