Hi,
someone gave me a help on this before I think it’s 1yr ago but I forgot his name and the original thread is from the old forum…
EDIT: here’s the old forum link: http://themeforest.net/forums/thread/remove-auto-assign-for-custom-fields/132163
if ((defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) || (defined('DOING_AJAX') && DOING_AJAX)) return;
if ( 'page' == isset($_POST['post_type']) ) { if ( !current_user_can( 'edit_page', $post_id ) ) return;
} else { if ( !current_user_can( 'edit_post', $post_id ) ) return; }
$arch_fields = array( 'bgslide', 'bgimage' );
foreach ($arch_fields as $arch_value) {
if( isset($arch_value) ) :
$arch_new = false;
$arch_old = get_post_meta( $post_id, $arch_value, true );
if ( isset( $_POST[$arch_value] ) ) :
$arch_new = $_POST[$arch_value];
endif;
if ( isset( $arch_new ) && '' == $arch_new && $arch_old ) :
delete_post_meta( $post_id, $arch_value, $arch_old );
elseif ( false === $arch_new || !isset( $arch_new ) ) :
delete_post_meta( $post_id, $arch_value, $arch_old );
elseif ( isset( $arch_new ) && $arch_new != $arch_old ) :
update_post_meta( $post_id, $arch_value, $arch_new );
elseif ( ! isset( $arch_old ) && isset( $arch_new ) ) :
add_post_meta( $post_id, $arch_value, $arch_new );
endif;
endif;
}
the issue on this code is that it will remove the custom fields data when save as bulk edit… can anyone help me fix this?
Thank you in advance…