jonB-5
Support threads created in the last 30 days: 0
Favorite Forum Topics
This user has no favorite topics.
Forum Topics Created
Status | Topic | Supporter | Voices | Posts | Freshness |
---|---|---|---|---|---|
Unable to get Facebook Pixel JS to work in Layouts JS Editor
Started by: jonB-5
in: Toolset Professional Support
Problem: I want to insert the following code in Layouts JS to include a Facebook Pixel tracker: <!-- Facebook Pixel Code --> <script> !function(f,b,e,v,n,t,s) {if(f.fbq)return;n=f.fbq=function(){n.callMethod? n.callMethod.apply(n,arguments):n.queue.push(arguments)}; if(!f._fbq)f._fbq=n;n.push=n;n.loaded=!0;n.version='2.0'; n.queue=[];t=b.createElement(e);t.async=!0; t.src=v;s=b.getElementsByTagName(e)[0]; s.parentNode.insertBefore(t,s)}(window, document,'script', 'https://connect.facebook.net/en_US/fbevents.js'); fbq('init', '1643227992405344'); fbq('track', 'PageView'); </script> <noscript><img height="1" width="1" style="display:none" src="https://www.facebook.com/tr?id=1643227992405344&ev=PageView&noscript=1" /></noscript> <!-- End Facebook Pixel Code --> Solution: You can't add HTML to the Layouts JS panel, and the snippet provided uses HTML to provide a fallback for non-JavaScript users. If you disregard non-JavaScript users, you can add only the JavaScript portion of this code to Layouts JS: !function(f,b,e,v,n,t,s) {if(f.fbq)return;n=f.fbq=function(){n.callMethod? n.callMethod.apply(n,arguments):n.queue.push(arguments)}; if(!f._fbq)f._fbq=n;n.push=n;n.loaded=!0;n.version='2.0'; n.queue=[];t=b.createElement(e);t.async=!0; t.src=v;s=b.getElementsByTagName(e)[0]; s.parentNode.insertBefore(t,s)}(window, document,'script', 'https://connect.facebook.net/en_US/fbevents.js'); fbq('init', '1643227992405344'); fbq('track', 'PageView'); To use the HTML fallback, you must enqueue this script some other way. Some themes provide places where you can insert custom code like this from wp-admin. Some do not, and you must enqueue the code manually instead. See below. Relevant Documentation: http://www.wpbeginner.com/wp-tutorials/how-to-install-facebook-remarketingretargeting-pixel-in-wordpress/ |
2 | 3 | 6 years, 10 months ago | ||
CRED Commerce – Paypal Says Cart is Empty
Started by: jonB-5 in: Toolset Professional Support |
2 | 17 | 6 years, 10 months ago | ||
Should I be using Toolset Starter or Toolset Starter Child?
Started by: jonB-5 in: Toolset Professional Support |
2 | 2 | 7 years ago | ||
SyntaxError: Unexpected token '
Started by: jonB-5 in: Toolset Professional Support |
2 | 2 | 7 years ago | ||
Filter Based on Shortcode Attribute in Queried Post Equalling Current Post ID
Started by: jonB-5 in: Toolset Professional Support |
3 | 13 | 7 years ago | ||
Dynamically Link Guest Users to CRED Forms Where Parent Posts are Pre-Selected
Started by: jonB-5 in: Toolset Professional Support |
2 | 14 | 7 years ago | ||
Creating Functions for Inventory Management
1
2
3
4
Started by: jonB-5 in: Toolset Professional Support |
2 | 49 | 7 years ago | ||
How to Get Child Post Fields to Inherit Values of Parent Post Fields by Default
1
2
Started by: jonB-5
in: Toolset Professional Support
Problem: Solution: You can find proposed solution with the following reply: Relevant Documentation: |
2 | 24 | 7 years, 1 month ago | ||
Calculating the sum of custom field values across multiple Child posts
Started by: jonB-5
in: Toolset Professional Support
Problem: A Voyage has 4 Child Tickets: What I need to do is summarise these values and display the total (which would be 19 in this example) in the Parent Voyage. Solution: add_shortcode('sum-of-tickets-available', 'sum_of_tickets_available_func'); function sum_of_tickets_available_func(){ $voyage_id = get_the_ID(); $children = get_posts( array( 'post_type'=> $child_slug, 'meta_query' => array( array( 'key' => '_wpcf_belongs_voyage_id', 'value' => $voyage_id, ), ), 'fields' => 'ids' ) ); $sum = 0; foreach($children as $id){ $sum += get_post_meta( $id, 'wpcf-total-tickets-available', true); } return $sum; } 2) Then in a single "Voyage" post, display the total value with shortcode: Relevant Documentation: |
2 | 4 | 7 years, 1 month ago | ||
CSV or XML Import and Export of Custom Post Types and Views
Started by: jonB-5 in: Toolset Professional Support |
3 | 9 | 7 years, 1 month ago | ||
Dynamic checkboxes field to associate Users with custom posts created in CRED
Started by: jonB-5
in: Toolset Professional Support
Problem: ... <wpv-loop> [wpv-item index=1]{"value":"[wpv-user field="ID"]","label":"[wpv-user field="display_name"]"} [wpv-item index=other],{"value":"[wpv-user field="ID"]","label":"[wpv-user field="display_name"]"} </wpv-loop> ... 2) Create a CRED form with a generic field, use above view as the options of this generic field, like this: [cred_generic_field field='my-generic-field' type='select' class='' urlparam=''] { "required":0, "validate_format":0, "persist":1, "default":[], "options":[ [wpv-view name="my-user-view"] ] } [/cred_generic_field] 3) when user submit the CRED form, use action hook "cred_save_data" to save the value into database Relevant Documentation: |
2 | 9 | 7 years, 1 month ago | ||
Limit Numerical Field Value in Child to the Value of Numerical Field in Parent
Started by: jonB-5
in: Toolset Professional Support
Problem: I would like to use back-end validation to ensure that a User is not able to create a post with a numeric custom field value that is higher than a numeric custom field value set in its parent post. Solution: Use the cred_form_validate hook to perform validation checks against the submitted value and the parent value: add_filter('cred_form_validate','my_variation_validation',10,2); function my_variation_validation($error_fields, $form_data) { //field data are field values and errors list($fields,$errors)=$error_fields; $forms = array( 12345, 23456, 34567 ); //validate if specific form if ( in_array( $form_data['id'], $forms )) { $ticketID = $fields['_wpcf_belongs_ticket_id']['value']; $ticketsAvailable = intval(get_post_meta($ticketID, 'wpcf-total-tickets-available', true)); if (intval($fields['wpcf-total-available-for-variation']['value']) > $ticketsAvailable) { //set error message for the total available field $errors['wpcf-total-available-for-variation']='A maximum of ' . $ticketsAvailable . ' variation(s) can be added.'; } } //return result return array($fields,$errors); } Replace 12345, 23456, 34567 with a comma-separated list of forms where this validation should be applied. Relevant Documentation: https://toolset.com/documentation/programmer-reference/cred-api/#cred_form_validate |
2 | 5 | 7 years, 1 month ago | ||
Unique URLs for Specific CPTs Created Though CRED
Started by: jonB-5
in: Toolset Professional Support
Problem: I would like to use a unique number as the title and URL slug of all posts created by a CRED form. Solution: Use the cred_save_data hook to update the post with the correct information: add_action('cred_save_data', 'auto_title_action',10,2); function auto_title_action($post_id, $form_data) { $forms = array( 123, 456 ); // if a specific form if ( in_array( $form_data['id'], $forms ) ) { $my_post = array( 'ID' => $post_id, 'post_title' => $post_id, 'post_name' => $post_id ); // Update the post in the database wp_update_post( $my_post ); } } Replace 123, 456 with a comma-separated list of forms where this automatic title should be applied. Relevant Documentation: https://toolset.com/documentation/programmer-reference/cred-api/#cred_save_data |
2 | 3 | 7 years, 1 month ago | ||
After creating a new Layout it is not available to be set as a Parent to a Child
Started by: jonB-5 in: Toolset Professional Support |
2 | 3 | 7 years, 1 month ago | ||
Unable to see a custom post type in Appearance > Menus
Started by: jonB-5
in: Toolset Professional Support
Problem: I cannot find a custom post type in the Menu management screen. I have enabled the "show in nav menus" option for this post type, but it still does not appear. Solution: Check the Screen Options tab and make sure the CPT is enabled here as well. |
2 | 3 | 7 years, 1 month ago |