sitenerds
Forum Replies Created
-
Hi,
Thanks for this, it seems to have worked. However, it has created a new issue where the post data field is not posting the data to the post type.
The submission is showing in the backend in the submissions area of forminator but not being posted.
I tried removing the snippet but it seems to have caused a permanent effect as it doesn’t work even after removing it. However, when I try on a staging instance that I have never used the snippet on, it works.
Can you advise?
Hi again,
Sorry one more question, if I wanted to add multiple category IDs, how could I add that into the code?
Hello,
Perfect, that worked! Looks like the category needed to be that of the specific custom post type and not WP posts.
Thanks so much for the team’s perseverance on this. Really appreciated.
Here is the code I have implemented:
<?php add_action( 'wp_head', function() { global $post; if ( is_a( $post, 'WP_Post' ) && ! has_shortcode( $post->post_content, 'forminator_form' ) ) { return; } $form_id = 317; $cat_id = 50; $cond_field = 'number-2'; ?> <script type="text/javascript"> jQuery(document).bind("ready ajaxComplete", function(){ if(jQuery('#forminator-module-<?php echo $form_id; ?> select[name="postdata-1-category"]').val() == <?php echo $cat_id; ?>) { jQuery("#<?php echo $cond_field; ?>").removeClass("forminator-hidden"); } else { jQuery("#<?php echo $cond_field; ?>").addClass("forminator-hidden"); } jQuery('#forminator-module-<?php echo $form_id; ?> select[name="postdata-1-category"]').bind("select2:select", function(e){ if(jQuery(this).val() == <?php echo $cat_id; ?>) { jQuery("#<?php echo $cond_field; ?>").removeClass("forminator-hidden"); } else { jQuery("#<?php echo $cond_field; ?>").addClass("forminator-hidden"); } }); }); </script>; <?php } );
And here is the URL: https://staging2.alih33.sg-host.com/register-form/
The expected conditional business category is meant to be “Baking”
Hello,
Thanks for clarifying. So the number field correctly is hidden on the front-end when the snippet is implemented, however it does not seem to be showing when I have the category in the post selected.
I went into the category and found the id 50 from the following url: term.php?taxonomy=hp_listing_category&tag_ID=50&post_type=hp_listing
Having replaced this in the snippet, the the field doesn’t show up as expected with the category selected: https://ibb.co/C5pHHqR
The field doesn’t appear with any of the other categories selected either (tested incase there was an issue with the id).
Hello again,
I am still getting the same output. The options in for conditional logic do not show the post category: https://ibb.co/PwnWR1z
Hi @wpmudev-support2 / @wpmudevsupport14
Loading form with AJAX was unchecked and I still am not able to select the category in the conditional logic.
Please see export here: https://docs.google.com/document/d/1IWg5EcKrb_-KNPXnH4bucQiErzRp_BZVXF6n_DvwREU/edit?usp=drive_link
- This reply was modified 7 months, 3 weeks ago by sitenerds.
Hi Nebu,
No worries, thanks for the reply.
I implemented the code as a mu-plugin as instructed, changed the form ID and added in my category ID and it still did not change anything. I still get the same options in the conditional logic: https://ibb.co/ykk05dp
Hi Kris,
Thanks for looking into this. I tried the snippet but it didn’t seem to work. Could you double-check that it is correct?
For clarity, I separated the JavaScript and PHP codes and input them separately using the WP Code Snippets plugin.