[Forminator Pro] Forminator conditional logic on hidden fields

I\'ve just installed this plugin and created a test form at https://test.citizensclimatelobby.uk/show-the-love-feedback/
I\'ve set up some conditional logic on some of the fields, but trying to get the email address field to show only when the user is not logged in (so the hidden email field is empty) is not working. It seems to always show that email field.

Also, the styling of the radio buttons looks wrong - the label is right up against the button. Same for checkboxes. I can\'t see any of my style rules overriding those of the plugin.

  • Ash

    Hello Turnpiece

    trying to get the email address field to show only when the user is not logged in

    How are trying to set this conditional logic? Please let me know the steps and I will try.

    Also, the styling of the radio buttons looks wrong - the label is right up against the button. Same for checkboxes. I can\'t see any of my style rules overriding those of the plugin.

    This is because your theme is overrideing the styling somehow. You may check the styling from default theme here: http://take.ms/WPP3E

    Would you please try using another theme and check this?

    Have a nice day!

    Cheers,
    Ash

  • Turnpiece

    Hi Ash

    For the conditional logic, I first tried setting the visible email field to show if the hidden email field was null but when that didn't work I tried setting it to be hidden if the hidden email field or the hidden name field were not null. Neither of these worked. When logged in the email field shows, even though I can see in the HTML source that my email address and name are there in the hidden fields.

  • Ash

    Hello Turnpiece

    Ahh, thanks a lot for explaining. The conditional logic for on-the-go values, not for pre-filled values. But we have plan to add a condition like, to show a field if user is logged in or not. By then, it won't be any problem.

    I don't have any ETA for that feature yet though, but I can confirm that it's going to be added.

    There is a tricky way for now though. Add a custom class for email field, for example, my_email. Then you can use the following code:

    add_action( 'wp_head', function() {
    	if( is_user_logged_in() )
    	{
    		?>
    		<style>.my_email{display: none !important}</style>
    		<script type="text/javascript">
    			jQuery(function($){
    				$('.my_email input[type=email]').val( $('input.forminator-hidden--field').val() );
    			});
    		</script>
    		<?php
    	}
    } );

    You can use this code in your child theme's functions.php if the theme is not changed. Otherwise mu-plugin is the best option. To create a mu-plugin, go to wp-content/mu-plugins folder. If there is no mu-plugins folder then, create one. Now, inside the mu-plugins folder create file with name anything.php (make sure file extension is .php). Now start with a <?php tag and then put the above code.

    Hope it helps! Please feel free to ask more questions if you have any.

    Have a nice day!

    Cheers,
    Ash

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.