Some fields won't save when using Include/Exclude

Support MB Include Exclude Some fields won't save when using Include/ExcludeResolved

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #28210
    Stephen C.Stephen C.
    Participant

    I'm using Include/Exclude to include meta boxes on a frontend form, while making sure they don't show up on the form in the admin area (which already has the fields provided by a plugin). The meta boxes display properly based on the include parameters, but a few field types won't save unless I remove the Include/Exclude code.

    Image select/upload, date and datetime all fail to save when using Include/Exclude code, even though they display properly.

    The only Include/Exclude code I am using on the meta boxes is:

    'include' => array(
         'template' => array( 'template-single-form.php' )
    ),

    If I remove the Include/Exclude code, the fields save fine, but then I end up with those meta boxes showing up on the admin form, which I can't have since those fields already exist on the admin form.

    Any ideas of how to get this to work? Thanks

    #28217
    Long NguyenLong Nguyen
    Moderator

    Hi Stephen,

    This is not the way of the extension MB Include Exclude works. If you set a meta box shows when the page/post has the template abc123.php, it will show in the backend (admin area) if you select the template here https://share.getcloudapp.com/QwuEpooy

    If you want to show a meta box and custom fields on the frontend form only, you can check if the admin area does not load.

    function my_custom_meta_boxes( $meta_boxes ){
        if( !is_admin() ) {
            $meta_boxes[] = array (
                 ...
            );
        }   
        return $meta_boxes;
    }
    
    #32941
    Stephen C.Stephen C.
    Participant

    Just an FYI: Using !is_admin() causes those fields not to be saved when submitting the form via ajax.

    Using

    if( wp_doing_ajax() || !is_admin() ) {

    seems to work, though.

Viewing 3 posts - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.