Support Forum
Support › Meta Box Conditional Logic › Conditional Meta Box Does Not Work on Frontend
I have a radio button on the frontend form, when selected it should display specific meta boxes.
The issue is on the frontend, Conditional Logic is working perfectly for fields, but it does nothing on the hiding or showing the actual meta box itself.
I tested the same code in the backend custom post type and it works perfectly. It displays and hides the meta box as it should. But on the frontend nothing happens. I have even tried Meta Box Show Hide and the same results as well.
Ideas?
Also forgot to say... I'm using the Metabox AIO.
I turned off Conditional Logic in Metabox AIO and uploaded the individual plugin and everything work fine. So it's something with Metabox AIO that's missing for Conditional Logic.
Hi Armand,
Can you please share the code that creates the fields and logic on your site? You can also troubleshoot the issue by deactivating all plugins except Meta Box, Meta Box AIO and switching to the standard theme of WordPress (Twenty TwentyOne).
Here's the code I am using. Like I said it works perfectly with the individual plugin, but not with AIO.
$meta_boxes[] = [
'title' => 'What Kind of Player',
'post_types' => 'ctavideos',
'id' => 'ctavideos_decision_player_metabox',
'class' => 'fieldwrapper',
'fields' => [
[
'type' => 'heading',
'name' => 'What kind of player do you want to create?',
'desc' => 'Choose the kind of player you want to create by selecting your option below.',
],
[
'name' => 'Select The Type of Player',
'id' => 'ctavideos_kind_of_player',
'type' => 'radio',
'options' => array(
'standard' => 'Standard Player',
'ctaplayer' => 'Call To Action',
'playlistplayer' => 'Playlist Player',
),
//'inline' => true,
'columns' => 12,
],
]
];
$meta_boxes[] = [
'title' => 'Video Playlist',
'post_types' => 'ctavideos',
'id' => 'ctavideos_playlist_metabox',
'hidden' => array( 'ctavideos_kind_of_player', '!=', 'playlistplayer' ),
'class' => 'fieldwrapper',
'columns' => 12,
'fields' => [
[
'type' => 'heading',
'name' => 'Video Playlist',
'desc' => 'Enter the details below for your videos and information you want in the playlist.',
],
[
'id' => 'playlist_group_id',
'type' => 'group',
'clone' => true,
'add_button' => 'Add Another Video',
'sort_clone' => true,
'group_title' => 'Playlist Video Details',
'collapsible' => 'false',
'fields' => array(
array(
'name' => 'Upload Your Video',
'id' => 'ctavideos_playlist_videos',
'type' => 'file_input',
'placeholder' => 'Enter the url of your call to action.',
),
array(
'name' => 'Link Text',
'id' => 'ctavideos_playlist_link_text',
'type' => 'text',
'placeholder' => 'Enter the button text. ie.) Click Here',
),
array(
'name' => 'Poster Image',
'id' => 'ctavideos_playlist_poster',
'type' => 'file_input',
),
),
],
]
];
Hi,
You need to include two meta box IDs in the frontend shortcode to make the conditional logic works on the frontend. It's just the JavaScript code to show/hide HTML elements.
[mb_frontend_form id='ctavideos_decision_player_metabox,ctavideos_playlist_metabox']