Beaver Builder Conditional Logic Help
Support › MB Beaver Builder Integration › Beaver Builder Conditional Logic HelpResolved
- This topic has 16 replies, 3 voices, and was last updated 4 years, 9 months ago by
[email protected].
-
AuthorPosts
-
April 3, 2020 at 11:39 AM #18829
[email protected]
ParticipantI've been trying to get this to work but in the Beaver themer conditional settings I put it under Meta Box > Post Field, add the correct key (the ID of my custom post field) and put it to "Is Set" or "Is not set" Nothing happens. Is this the correct setting? I want certain fields to disappear based on whether a Custom field has information in it. Please help. Thanks.
Here is what I am speaking of as a video.
https://share.getcloudapp.com/v1urq1Y4?fbclid=IwAR0oTs0Di7uXgtqIYwuj12j8b2DDiKb06Mwcdc-Vlwyc9bwWsxQXPPRJ3lsThank you.
April 3, 2020 at 4:28 PM #18834Long Nguyen
ModeratorHi,
The right ID of the field is
$prefix . 'field_id'
, could you please check the$prefix
variable above the code if it has any string? Or share the code that you use to create the field.April 4, 2020 at 12:49 AM #18837[email protected]
ParticipantHi Long,
Thanks for writing. I have been putting the prefix into the beaver themer conditional logic fields. Here is a video showing my process. Perhaps I'm missing something.https://share.getcloudapp.com/2NuB49de
Thanks
Here is the code for one of the fields:
array (
'id' => $prefix . 'text_gm0xjjhubsv',
'type' => 'text',
'name' => esc_html__( 'Speaker Name', 'text-domain' ),
'tab' => 'tab_nqd2avvq8wd',
),April 4, 2020 at 10:22 AM #18845Long Nguyen
ModeratorHi,
Let's see the simple custom field for the post
add_filter( 'rwmb_meta_boxes', 'your_prefix_register_meta_boxes' ); function your_prefix_register_meta_boxes( $meta_boxes ) { $prefix = 'your_prefix_'; // check your prefix here $meta_boxes[] = array ( 'title' => esc_html__( 'Text', 'text-domain' ), 'id' => 'text', 'post_types' => array( 0 => 'post', ), 'context' => 'normal', 'priority' => 'high', 'fields' => array( array ( 'id' => $prefix . 'text_field', 'type' => 'text', 'name' => esc_html__( 'Text Field', 'text-domain' ), ), ), ); return $meta_boxes; }
after connect to show the Meta Box Field, you can check the conditional logic with the field id
your_prefix_text_field
. I've created a screen record for this case https://cl.ly/1210e564df6fMay 2, 2020 at 5:02 AM #19415[email protected]
ParticipantI have a similar problem trying to use BB Conditional Logic to hide a column if the custom avatar is not set (https://metabox.io/create-custom-avatar/?fbclid=IwAR3I1M2s71PFAQgNdhAk5tuAXqhyKU46WP-qJZvOVKBxKBbjdYAAB4vX5u4 )
I'm editing the column where the Post Author Image is placed using Themer, and then setting Conditional Logic for the column to show if:
$prefix . 'custom_avatar'
is set
But even when the custom_avatar is set the column is still hidden.
Any ideas?
May 2, 2020 at 9:26 AM #19420Long Nguyen
Moderator@hartsook
The
$prefix
is the variable in the code, please use its value when you add the field ID to conditional logic. If you use the Builder to create the field, click to the tab Code to get it.For this case, it's empty so the field ID is
custom_avatar
.Another example when creating the field with the code https://cl.ly/1a3053aad345
the field ID to use in this case issettings_test_single_id
Hope that makes sense.
May 2, 2020 at 9:38 AM #19421[email protected]
Participantyes, the way that Long showed me is that i was missing the first prefix for the filter. You have to put both in the conditional logic field. https://share.getcloudapp.com/mXuBKPNG
in the picture the highlighted field is the first prefix. Both prefixes need to be together for it to work.
May 5, 2020 at 6:09 AM #19462[email protected]
ParticipantNow one more step. I actually want to hide the column the image is in if NEITHER the gravatar nor the custom_avatar image is set. If the author has a gravatar and not a custom_avatar then show, if the author has a custom_avatar then show, but if no image is set, hide the column using the Themer conditional logic.
Which trigger do I use and what would the key be if that is required?
Trying to understand the specific case here as well as the generalization so I can use the conditional logic in other places like an author archive page for example.
May 5, 2020 at 10:57 AM #19468Long Nguyen
Moderator@hartsook
Because WordPress gets the user profile picture from Gravatar by ID or email and not save any image information to the database so we can only check the condition of custom avatar which is created by Meta Box and save to the database as a user meta with Beaver Builder.
You can follow the documentation
https://developer.wordpress.org/reference/functions/get_avatar/
https://developer.wordpress.org/reference/functions/get_avatar_data/to check both conditions: available Gravatar and available custom avatar with coding.
July 2, 2020 at 5:25 AM #20583[email protected]
ParticipantHi, this is following on the heels of my last question about Beaver Builder Conditional Logic.
- I created a settings page in the functions.php file for my theme.
- I want to be able to activate a BB module if a particular field is filled in.
- If that field is filled in, I also want another section to deactivate.
Unlike the custom Post Types, the settings page doesn't seem to have a prefix. I'm stuck. Can you please let me know if this is possible to use the settings page with the beaver conditional logic? or is there a different way to achieve what I'm trying to do?
https://share.getcloudapp.com/p9uPQYPJ
My last question is this. Should the settings code be added to the theme settings file, or is it better to add it a different way?
Thank you,
EricJuly 2, 2020 at 9:38 AM #20588Long Nguyen
ModeratorHi,
When opening the Beaver conditional logic, you can scroll down and select the option Settings Page Field then choose the setting page and type the field ID. See more in my screen record https://www.loom.com/share/7da0e7f10b184985990ed90ea49c7fb1.
Regarding the settings code, I recommend adding it to the file functions.php in the child theme folder or use the plugin Code Snippets to avoid losing this code when updating the new version of the theme.
July 2, 2020 at 10:25 AM #20590[email protected]
Participantok, so I did figure out how to set the settings page.
https://www.dropbox.com/s/mr9f2flkjn2wxoy/Screenshot%202020-07-01%2023.18.41.png?dl=0
Now I can't seem to get other modules to turn off if the site setting field is filled in.
https://www.dropbox.com/s/gge8mir33oy3giu/Screenshot%202020-07-01%2023.21.36.png?dl=0
There is no "Is Not Set" only the "Is Set" option. I tried the other "equals" and "not equal" but I'm not sure what too put as the value. I tried "none" but that didn't work. Any suggestions on this?
Thank you,
EricJuly 2, 2020 at 11:14 AM #20592Long Nguyen
ModeratorHi Eric,
You can use the option "Is Set" to show a section. That means if the field has any value (not empty) it will match with the condition Is Set, just like the field
text
you can type any text to the field.If you use the option "Equals" the value of the field must have exactly the value in Equals to show the section.
July 2, 2020 at 5:32 PM #20600[email protected]
Participanthi Long
Thanks for your reply.
I see what you are saying. The field value for that specific field will change every time depending on the client so it won't have the same value.Why is there a "Is Set" and not a "Is not set" option as there is in the MB post option?
https://www.dropbox.com/s/n7rlsi48zffksd5/Screenshot%202020-07-02%2006.31.45.png?dl=0This video may be a little more clear in the understanding: https://share.getcloudapp.com/2Nu57gr0
Thank you,
ericJuly 2, 2020 at 9:04 PM #20603[email protected]
ParticipantHi,
I was able to accomplish this task using the Buttons function instead of the switch. It let me set the values for the "Equals" option.https://www.dropbox.com/s/yjdqfgv8gv9xhr7/Screenshot%202020-07-02%2010.03.14.png?dl=0
I guess i'm still wondering though. Why is there a “Is Set” and not a “Is not set” option as there is in the MB post option?
Thanks,
Eric -
AuthorPosts
- You must be logged in to reply to this topic.