Файловый менеджер - Редактировать - /home/admin/domains/octawebtools.com/public_html/wp-content/uploads/wpcode/cache/library/profile_wpforms.json
�азад
{"categories":[{"name":"WPForms Team","slug":"wpforms"}],"snippets":[{"library_id":14095,"title":"Accordion Template Helper","code":"\/**\r\n * For the Accordion Template, this is a helper script\r\n * \r\n * For support, please visit: https:\/\/www.facebook.com\/groups\/wpformsvip\r\n *\/\r\nadd_action( 'wp_head', function () { ?>\r\n \r\n <style>\r\n \/* CSS magic to hide the page breaks and display section dividers as \"buttons\" based on the form class name *\/\r\n\t\t.wpf-accordion-form .wpforms-page,\r\n\t\t.wpf-accordion-form .wpforms-submit-container {\r\n\t\t\tdisplay: block!important;\r\n\t\t}\r\n\t\t\r\n\t\t.wpf-accordion-form .wpforms-page-prev,\r\n\t\t.wpf-accordion-form .wpforms-page-next {\r\n\t\t\tdisplay: none!important;\r\n\t\t}\r\n\t\t\r\n\t\t.wpf-accordion-form .wpforms-field-divider {\r\n\t\t\tpadding: 0;\r\n\t\t\tborder: 0;\r\n\t\t}\r\n\t\t\r\n\t\t.wpf-accordion-form .wpforms-field-divider h3 {\r\n\t\t\tfont-size: 18px;\r\n\t\t\tpadding: 25px;\r\n\t\t\tborder: 1px solid #eee;\r\n\t\t\tborder-radius: 4px;\r\n\t\t\tcursor: pointer;\r\n\t\t}\r\n\t\t.wpf-accordion-form div:not(.wpforms-layout-column) > .wpforms-field:not(.wpforms-field-divider) {\r\n\t\t\tdisplay: none;\r\n\t\t}\r\n\t\t.wpf-accordion-form .wpforms-field-divider h3:before {\r\n\t\t\tcontent: '\u2193';\r\n\t\t\tmargin-right: 10px;\r\n\t\t}\r\n <\/style>\r\n \r\n<?php } );\r\n \r\n\/\/ Enable section dividers to act like accordion toggles\r\nfunction wpf_accordion_form() {\r\n ?>\r\n <script>\r\n\t\t( function( document, window, $ ) {\r\n\t\t\t$( '.wpf-accordion-form .wpforms-field-divider' ).on( 'click', function() {\r\n\t\t\t\tconst $this = $( this );\r\n\t\t\t\tif ( $this.hasClass( 'active' ) ) {\r\n\t\t\t\t\t$this.removeClass( 'active' );\r\n\t\t\t\t\t$this.nextUntil( '.wpforms-field-divider' ).hide();\r\n\t\t\t\t\treturn;\r\n\t\t\t\t}\r\n\t\t\t\t$this.nextUntil( '.wpforms-field-divider' ).show();\r\n\t\t\t\t$this.addClass( 'active' );\r\n\t\t\t})\r\n\t\t}( document, window, jQuery ) );\r\n <\/script>\r\n <?php\r\n}\r\nadd_action( 'wpforms_wp_footer_end', 'wpf_accordion_form', 10 );","note":"This snippet will allow you to use Section Divider fields in an \"accordion-like\" manner by...","categories":["wpforms"],"code_type":"php","needs_auth":false,"tags":["templates"],"max_version":""},{"library_id":17943,"title":"Add Autofocus on Your Form","code":"\/* \r\nAdd autofocus to the first form field of the form\r\n\r\nOriginal doc link: https:\/\/wpforms.com\/developers\/how-to-add-autofocus-on-your-form\/\r\n\r\nFor support, please visit: https:\/\/www.facebook.com\/groups\/wpformsvip\r\n*\/\r\n\r\nfunction wpf_dev_autofocus() {\r\n?>\r\n<script type=\"text\/javascript\">\r\n jQuery(document).ready(function() {\r\n \r\n var first_input = jQuery( 'form.wpforms-form input[type=text]:visible:enabled:first, textarea:visible:enabled:first' )[0];\r\n \r\n if (first_input != undefined) {\r\n first_input.focus();\r\n }\r\n \r\n });\r\n<\/script>\r\n<?php\r\n}\r\nadd_action( 'wpforms_wp_footer_end', 'wpf_dev_autofocus', 10 );","note":"This snippet adds auto focus to the first field of your form when the page...","categories":["wpforms"],"code_type":"php","needs_auth":false,"tags":[],"max_version":""},{"library_id":6192,"title":"Add Field Values for Dropdown, Checkboxes, and Multiple Choice Fields","code":"\/**\r\n * Add field values for dropdown, checkboxes, and multiple choice fields\r\n *\r\n * @link https:\/\/wpforms.com\/developers\/add-field-values-for-dropdown-checkboxes-and-multiple-choice-fields\/\r\n * \r\n * For support, please visit: https:\/\/www.facebook.com\/groups\/wpformsvip\r\n *\/\r\n\r\nadd_filter( 'wpforms_fields_show_options_setting', '__return_true' );","note":"Adds the option to display field values for Dropdown, Checkboxes, and Multiple Choice fields. Once...","categories":["wpforms"],"code_type":"php","needs_auth":false,"tags":["field-values"],"max_version":""},{"library_id":23132,"title":"Add Redirection to Custom Password Reset Form","code":"\/* \r\nRedirect Lost Password to Custom Password Reset \r\n\r\nOriginal doc link: https:\/\/wpforms.com\/how-to-customize-the-wordpress-password-reset-form\/\r\n\r\nFor support, please visit: https:\/\/www.facebook.com\/groups\/wpformsvip\r\n*\/\r\n\r\nfunction my_custom_lostpassword_url() {\r\n return home_url( '\/reset-password\/' );\r\n}\r\n\r\nadd_filter( 'lostpassword_url', 'my_custom_lostpassword_url' );","note":"With this filter you can redirect any lost password requests to a custom reset form","categories":["wpforms"],"code_type":"php","needs_auth":false,"tags":[],"max_version":""},{"library_id":23030,"title":"Adding a Background Image to Your Forms","code":"\/* \r\nAdding a background image to your forms.\r\n\r\nOriginal doc link: https:\/\/wpforms.com\/docs\/how-to-add-a-background-image-in-wpforms\/\r\n\r\nFor support, please visit: https:\/\/www.facebook.com\/groups\/wpformsvip\r\n*\/\r\n\r\n.wpf-custom-background {\r\n background-image: url(\/path\/wpforms-backdrop.png) !important;\r\n padding: 15px 35px !important;\r\n \/*Padding is optional, but improves appearance when using a background image in your form.*\/\r\n}\r\n","note":"With this snippet, it follows the tutorial listed inside the Adding a Background Image to...","categories":["wpforms"],"code_type":"css","needs_auth":false,"tags":[],"max_version":""},{"library_id":32159,"title":"Adding a Video Before Your Form","code":"\/**\r\n * Output something before your form(s).\r\n * \r\n * @link https:\/\/wpforms.com\/developers\/how-to-add-a-video-before-your-form\/\r\n *\/\r\n\r\nfunction wpf_dev_frontend_output_before( $form_data, $form ) {\r\n \r\n \/\/ Optional, you can limit to specific forms. Below, we restrict output to\r\n \/\/ form #999.\r\n if ( absint( $form_data[ 'id' ] ) !== 999 ) {\r\n return;\r\n } \r\n \r\n \/\/ Add the link of your video here within this iframe code\r\n _e( '<p><iframe src=\"https:\/\/www.youtube.com\/embed\/eiQ3viAGung\" frameborder=\"0\" allow=\"accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture\" allowfullscreen><\/iframe><\/p>', 'plugin-domain' );\r\n \r\n}\r\nadd_action( 'wpforms_frontend_output_before', 'wpf_dev_frontend_output_before', 10, 2 );","note":"This code snippet will add a video above your form.","categories":["wpforms"],"code_type":"php","needs_auth":false,"tags":["wpforms"],"max_version":""},{"library_id":33507,"title":"Adding Custom Border to Your Form","code":"\/* Add custom border to specific form *\/\r\n#wpforms-form-1234 {\r\n border: 2px solid #333333;\r\n padding: 20px;\r\n border-radius: 5px;\r\n background-color: #ffffff;\r\n box-shadow: 0 0 10px rgba(0,0,0,0.1);\r\n}","note":"","categories":["wpforms"],"code_type":"css","needs_auth":false,"tags":[],"max_version":""},{"library_id":31496,"title":"Adding French Time Format for the Date \/ Time field","code":"\/**\r\n * Add additional formats for the Time field Format dropdown using French time format.\r\n *\r\n * @link https:\/\/wpforms.com\/developers\/how-to-create-additional-formats-for-the-date-time-field-time-picker\/\r\n *\/\r\n\r\nfunction wpf_dev_date_field_time_formats_french( $time_formats ) {\r\n\r\n\t$time_formats[ 'G\\\\\\hi\\\\\\m' ] = 'French Format';\r\n\r\n\treturn $time_formats;\r\n}\r\nadd_filter( 'wpforms_datetime_time_formats', 'wpf_dev_date_field_time_formats_french', 10, 1 );","note":"This code snippet adds a new French format to the Date \/ Time field.","categories":["wpforms"],"code_type":"php","needs_auth":false,"tags":[],"max_version":""},{"library_id":32579,"title":"Adding Images to Checkboxes","code":"ul#wpforms-1000-field_25 li.choice-1 label:before {\r\n content: \"\";\r\n display: inline-block;\r\n background-image: url(http:\/\/yoursite.com\/wp-content\/uploads\/2019\/10\/your-image-filename.png);\r\n background-size: 100%;\r\n height: 45px;\r\n width: 30px;\r\n background-repeat: no-repeat;\r\n position: relative;\r\n right: 5px;\r\n top: 20px;\r\n}","note":"This CSS snippet will add a background image to the labels of the Checkbox fields.","categories":["wpforms"],"code_type":"css","needs_auth":false,"tags":["wpforms"],"max_version":""},{"library_id":33515,"title":"Adding Material Design to Your Form Fields Using CSS","code":"#wpforms-form-697 { \r\n float: left; \r\n width: 100%; \r\n text-align: center; \r\n margin: 30px auto 30px auto; \r\n}\r\n \r\n#wpforms-form-697 .wpforms-field {\r\n margin-left: auto;\r\n margin-right: auto;\r\n max-width: 300px;\r\n margin-bottom: 15px;\r\n position: relative;\r\n}\r\n \r\n#wpforms-form-697 .wpforms-field input, \r\n#wpforms-form-697 .wpforms-field textarea {\r\n position: relative;\r\n display: block;\r\n width: 100%;\r\n border: none;\r\n border-bottom: 1px solid #ccc;\r\n background-color: transparent;\r\n margin: 0px auto;\r\n padding: 5px;\r\n outline: none !important;\r\n font-size: 14px;\r\n color: rgba(0,0,0,0.8);\r\n background: -webkit-linear-gradient(bottom, #51BBBE 50%, #51BBBE 50%);\r\n background: linear-gradient(to top, #51BBBE 50%, #51BBBE 50%);\r\n background-position: left bottom;\r\n background-size: 0 1px;\r\n background-repeat: no-repeat;\r\n transition: all .2s ease-in-out;\r\n max-width: 100%;\r\n}\r\n \r\n#wpforms-form-697 .wpforms-field label.wpforms-field-label {\r\n text-align: left;\r\n text-transform: uppercase;\r\n font-size: 13px;\r\n font-weight: 200;\r\n background: transparent;\r\n color: rgba(0,0,0,0.6);\r\n margin: 0px auto;\r\n cursor: text;\r\n transition: all .15s ease-in-out;\r\n}\r\n \r\n#wpforms-form-697 .wpforms-field input:focus, \r\n#wpforms-form-697 .wpforms-field textarea:focus { \r\n border-bottom: 1px solid #51BBBE;\r\n box-shadow: none;\r\n}\r\n \r\n#wpforms-form-697 .wpforms-field input:focus,\r\n#wpforms-form-697 .wpforms-field textarea:focus { \r\n background-position: left bottom;\r\n background-size: 100% 1px;\r\n}\r\n \r\n#wpforms-form-697 .wpforms-field input:focus + label.wpforms-field-label,\r\n#wpforms-form-697 .wpforms-field textarea:focus + label.wpforms-field-label { \r\n color: #51BBBE;\r\n}\r\n \r\n.wpforms-field.wpforms-has-error input.wpforms-error, \r\n.wpforms-field.wpforms-has-error textarea.wpforms-error {\r\n border-bottom: 1px solid #e57373 !important;\r\n background-color: transparent;\r\n background: transparent !important;\r\n}\r\n \r\n.wpforms-field.wpforms-has-error label.wpforms-field-label, \r\n.wpforms-field.wpforms-has-error label.wpforms-error {\r\n color: #e57373 !important;\r\n}","note":"","categories":["wpforms"],"code_type":"css","needs_auth":false,"tags":[],"max_version":""},{"library_id":32589,"title":"Adding Transitions to Checkbox and Multiple Choice Selections","code":"ul#wpforms-999-field_3 li label, \r\nul#wpforms-999-field_27 li label {\r\n padding: 10px;\r\n transition: all ease 0.3s;\r\n background: linear-gradient(to right, #e27730 50%, #cd631d 50%);\r\n background-size: 200% 100%;\r\n background-position: left bottom;\r\n color: white;\r\n}\r\nul#wpforms-999-field_3 li.wpforms-selected label, \r\nul#wpforms-999-field_3 li label:hover, \r\nul#wpforms-999-field_27 li.wpforms-selected label, \r\nul#wpforms-999-field_27 li label:hover {\r\n cursor: pointer;\r\n border-radius: 2px;\r\n background-position: right top;\r\n}\r\nul#wpforms-999-field_3 li input, ul#wpforms-999-field_27 li input {\r\n display: none;\r\n}\r\nul#wpforms-999-field_3 li, \r\nul#wpforms-999-field_27 li {\r\n float: left;\r\n width: auto;\r\n display: inline-block;\r\n padding: 10px !important;\r\n}","note":"","categories":["wpforms"],"code_type":"css","needs_auth":false,"tags":["wpforms"],"max_version":""},{"library_id":6186,"title":"Allow Date Range Selection in Date Picker","code":"\/**\r\n * Adds a date range inside the date picker field.\r\n *\r\n * @link https:\/\/wpforms.com\/developers\/allow-date-range-or-multiple-dates-in-date-picker\/\r\n * \r\n * For support, please visit: https:\/\/www.facebook.com\/groups\/wpformsvip\r\n *\/\r\n \r\nfunction wpf_dev_date_picker_range() {\r\n?>\r\n <script type=\"text\/javascript\">\r\n \r\n window.wpforms_datepicker = {\r\n mode: \"range\"\r\n }\r\n \r\n <\/script>\r\n<?php\r\n}\r\nadd_action( 'wpforms_wp_footer_end', 'wpf_dev_date_picker_range', 10 );","note":"Adds the ability to select a date range inside the Date Picker field.","categories":["wpforms"],"code_type":"php","needs_auth":false,"tags":["date-picker","date-range"],"max_version":""},{"library_id":6187,"title":"Allow Multiple Dates Selection in Date Picker","code":"\/**\r\n * Adds the ability to select multiple dates inside the Date Picker field\r\n *\r\n * @link https:\/\/wpforms.com\/developers\/allow-date-range-or-multiple-dates-in-date-picker\/\r\n * \r\n * For support, please visit: https:\/\/www.facebook.com\/groups\/wpformsvip\r\n *\/\r\n\r\nfunction wpf_dev_date_picker_multiple() {\r\n ?>\r\n <script type=\"text\/javascript\">\r\n \r\n window.wpforms_datepicker = {\r\n mode: \"multiple\"\r\n }\r\n \r\n <\/script>\r\n <?php\r\n}\r\nadd_action( 'wpforms_wp_footer_end', 'wpf_dev_date_picker_multiple', 10 );\r\n","note":"Adds the ability to select multiple dates inside the Date Picker field.","categories":["wpforms"],"code_type":"php","needs_auth":false,"tags":["date-picker","multiple-dates"],"max_version":""},{"library_id":32596,"title":"Approving User Account After Completed PayPal Payment","code":"\/**\r\n * Approve user after PayPal payment status is Complete\r\n *\r\n * @link https:\/\/wpforms.com\/developers\/how-to-approve-a-user-after-a-paypal-payment\/\r\n *\/\r\n \r\nfunction wpf_dev_activate_user_after_paypal_complete( $fields, $form_data, $payment_id, $data ){\r\n \r\n \/\/ Add the field ID for the user's account email\r\n $email_field = 3;\r\n \r\n \/\/ Stop editing\r\n $user = get_user_by( 'email', $form_data[ $email_field ][ 'value' ] );\r\n \r\n delete_user_meta( $user->ID, 'wpforms-activate' );\r\n delete_user_meta( $user->ID, 'wpforms-pending' );\r\n delete_user_meta( $user->ID, 'wpforms-confirmation' );\r\n \r\n \/\/ Check if we need to assign new role.\r\n $role = get_user_meta( $user->ID, 'wpforms-role', true );\r\n \r\n if ( $role ) {\r\n \r\n wp_update_user(\r\n [\r\n 'ID' => $user->ID,\r\n 'role' => $role,\r\n ]\r\n );\r\n delete_user_meta( $user->ID, 'wpforms-role' );\r\n }\r\n \r\n wpforms_user_registration()->get( 'email_notifications' )->after_activation( $user->ID );\r\n \r\n}\r\n \r\nadd_action( 'wpforms_paypal_standard_process_complete', 'wpf_activate_user_after_paypal_complete', 10, 4 );","note":"This snippet conditionally approves a user's account after they've completed their payment through the PayPal...","categories":["wpforms"],"code_type":"php","needs_auth":false,"tags":[],"max_version":""},{"library_id":33952,"title":"Assign User Role Conditionally in WordPress","code":"\/**\r\n * Assigns a specific WordPress user role based on the selected value in a WPForms multiple-choice field.\r\n * \r\n * @link https:\/\/wpforms.com\/how-to-assign-user-roles-conditionally-in-wordpress\/\r\n * \r\n * @param array $user_data Array containing user registration data.\r\n * @param array $fields Array of form fields and their submitted values.\r\n * @param array $form_data Array of form metadata, including the form ID.\r\n *\r\n * @return array Modified $user_data with the assigned role if a match is found.\r\n *\/\r\nfunction assign_role_during_registration( $user_data, $fields, $form_data ) {\r\n \/\/ The ID of your form and the field used for selecting the role\r\n $form_id = '13'; \/\/ Replace with your form ID\r\n $role_field_id = '6'; \/\/ Replace with the ID of your \"Multiple Choice\" field\r\n\r\n \/\/ Ensure we're working with the correct form\r\n if ( $form_data['id'] !== $form_id ) {\r\n return $user_data;\r\n }\r\n\r\n \/\/ Mapping values from the field to WordPress roles\r\n $role_mapping = [\r\n 'Student' => 'author',\r\n 'Teacher' => 'editor',\r\n ];\r\n\r\n \/\/ Retrieve the selected value from the field\r\n $selected_role = isset( $fields[ $role_field_id ]['value'] ) ? $fields[ $role_field_id ]['value'] : '';\r\n\r\n \/\/ Check if the selected value exists in the mapping\r\n if ( array_key_exists( $selected_role, $role_mapping ) ) {\r\n \/\/ Assign the corresponding role to the user\r\n $user_data['role'] = $role_mapping[ $selected_role ];\r\n }\r\n\r\n return $user_data;\r\n}\r\n\r\nadd_filter( 'wpforms_user_registration_process_registration_get_data', 'assign_role_during_registration', 10, 3 ); ","note":"This snippet works with WPForms and the User Registration Add-on. It lets you assign user...","categories":["wpforms"],"code_type":"php","needs_auth":false,"tags":[],"max_version":""},{"library_id":13523,"title":"Block IP Addresses From Completing Your Form","code":"\/**\r\n * Block form submissions based on IP address\r\n *\r\n * @link https:\/\/wpforms.com\/developers\/how-to-block-ip-addresses-from-completing-your-form\/\r\n * \r\n * For support, please visit: https:\/\/www.facebook.com\/groups\/wpformsvip\r\n *\/\r\n\r\nfunction wpf_ip_block( $fields, $entry, $form_data ) {\r\n \r\n \/\/ Get the current users IP address\r\n $ip_address = wpforms_get_ip();\r\n\r\n \/\/ Enter all IP addresses here, separated by a comma\r\n $blocked_ips = array(\r\n '129.222.6.90',\r\n '127.0.0.1',\r\n );\r\n \r\n \/\/ Check if the current user IP address is a blocked IP\r\n if ( in_array( $ip_address, $blocked_ips ) ) {\r\n\t\t\r\n \/\/ Block form submission and print error\r\n wpforms()->process->errors[ $form_data[ 'id' ] ] [ 'footer' ] = esc_html__( 'Your IP address has been blocked. Please contact the site administrator for further assistance.', 'text-domain' );\r\n }\r\n}\r\nadd_action( 'wpforms_process', 'wpf_ip_block', 10, 3 );","note":"Using this snippet will allow you to add specific IP Addresses from completing your forms.","categories":["wpforms"],"code_type":"php","needs_auth":false,"tags":[],"max_version":""},{"library_id":13496,"title":"Centering a form","code":"\/* \r\nCenter the form inside a container\r\n\r\nOriginal doc link: https:\/\/wpforms.com\/developers\/how-to-center-a-form\/\r\n\r\nFor support, please visit: https:\/\/www.facebook.com\/groups\/wpformsvip\r\n*\/\r\n\r\n.wpforms-container.wpf-center {\r\n margin: 0 auto !important;\r\n\/* Adjust the width in the next 2 lines as your site needs *\/\r\n max-width: 500px !important;\r\n width: 500px !important;\r\n}\r\n\r\n\/* Readjust the form width for smaller devices *\/\r\n@media only screen and (max-width: 600px) {\r\n\r\n\t.wpforms-container.wpf-center {\r\n\t\/* Reset the width for devices under 600px *\/\r\n\t\tmax-width: unset !important;\r\n\t\twidth: auto !important;\r\n}\r\n\t\r\n}","note":"This snippet will allow you to add a CSS class to your form which will...","categories":["wpforms"],"code_type":"css","needs_auth":false,"tags":[],"max_version":""},{"library_id":31676,"title":"Centering All Form Elements","code":"\/* Center the form container *\/\r\n.wpforms-container.wpf-center {\r\n margin: 0 auto !important;\r\n max-width: 500px !important;\r\n width: 500px !important;\r\n}\r\n\r\n\/* Center submit button and make it full width *\/\r\n.wpf-center .wpforms-submit-container {\r\n display: inline-block;\r\n text-align: center;\r\n width: 100% !important;\r\n}\r\n\r\n\/* Center page break elements *\/\r\n.wpf-center .wpforms-field-pagebreak {\r\n display: inline-block;\r\n text-align: center;\r\n width: 100% !important;\r\n}\r\n\r\n\/* Remove default page break button decorations *\/\r\n.wpf-center .wpforms-pagebreak-left .wpforms-page-button:before,\r\n.wpf-center .wpforms-pagebreak-left .wpforms-page-button:after {\r\n content: none;\r\n}\r\n\r\n\/* Center all text elements *\/\r\n.wpf-center .wpforms-title,\r\n.wpf-center .wpforms-description,\r\n.wpf-center .wpforms-field-label,\r\n.wpf-center .wpforms-field-sublabel,\r\n.wpf-center .wpforms-field-description {\r\n text-align: center;\r\n}\r\n\r\n\/* Mobile responsiveness *\/\r\n@media only screen and (max-width: 600px) {\r\n .wpforms-container.wpf-center {\r\n max-width: unset !important;\r\n width: auto !important;\r\n }\r\n}","note":"This CSS snippet will center everything inside the form (labels, descriptions, buttons).","categories":["wpforms"],"code_type":"css","needs_auth":false,"tags":["wpforms"],"max_version":""},{"library_id":6178,"title":"Change CSV Export Delimiter","code":"\/**\r\n * Filters the delimiter used in CSV exports of form entries\r\n * \r\n * @link https:\/\/wpforms.com\/developers\/change-csv-export-delimiter\/\r\n * \r\n * For support, please visit: https:\/\/www.facebook.com\/groups\/wpformsvip\r\n *\/\r\n \r\nfunction wpf_dev_pro_admin_entries_export_configuration( $configuration ) {\r\n \r\n $configuration[ 'csv_export_separator' ] = ';';\r\n \r\n return $configuration;\r\n \r\n}\r\n \r\nadd_filter( 'wpforms_pro_admin_entries_export_configuration', 'wpf_dev_pro_admin_entries_export_configuration', 10, 1 );\r\n","note":"Changes the CSV delimiter that separates each form field on a form export. Remember to...","categories":["wpforms"],"code_type":"php","needs_auth":false,"tags":["csv-export","export"],"max_version":""},{"library_id":6190,"title":"Change Position of v2 Invisible reCAPTCHA Badge","code":"\/**\r\n * Change position of v2 Invisible reCAPTCHA badge\r\n *\r\n * @link https:\/\/wpforms.com\/developers\/how-to-change-the-position-of-the-v2-invisible-recaptcha-badge\/\r\n * \r\n * For support, please visit: https:\/\/www.facebook.com\/groups\/wpformsvip\r\n *\/\r\n\r\nfunction wpf_dev_invisible_recaptcha_position( $data, $form_data ) {\r\n \r\n $type = wpforms_setting( 'recaptcha-type', 'v2' );\r\n if ( 'invisible' === $type ) {\r\n $data[ 'badge' ] = 'inline';\r\n }\r\n \r\n return $data;\r\n \r\n}\r\nadd_filter( 'wpforms_frontend_recaptcha', 'wpf_dev_invisible_recaptcha_position', 10, 2 );\r\n","note":"Changes the position of the v2 Invisible reCAPTCHA badge","categories":["wpforms"],"code_type":"php","needs_auth":false,"tags":["invisible-recaptcha"],"max_version":""},{"library_id":13455,"title":"Change Sublabels for the Email Field","code":"\/**\r\n * Customize email field properties.\r\n *\r\n * @link https:\/\/wpforms.com\/developers\/how-to-change-sublabels-for-the-email-field\/\r\n * \r\n * For support, please visit: https:\/\/www.facebook.com\/groups\/wpformsvip\r\n *\/\r\n \r\nfunction wpf_dev_email_field_properties( $properties, $field, $form_data ) {\r\n \r\n \/\/ Change the text for the sublabel\r\n $properties[ 'inputs' ][ 'primary' ][ 'sublabel' ][ 'value' ] = __( 'Enter Your Email', 'plugin-domain' );\r\n $properties[ 'inputs' ][ 'secondary' ][ 'sublabel' ][ 'value' ] = __( 'To confirm, re-enter your email address here', 'plugin-domain' );\r\n \r\n return $properties;\r\n \r\n}\r\n \r\nadd_filter( 'wpforms_field_properties_email' , 'wpf_dev_email_field_properties', 10, 3 );\r\n","note":"Using this snippet will allow you to customize the sublabels that appear under the Email...","categories":["wpforms"],"code_type":"php","needs_auth":false,"tags":[],"max_version":""},{"library_id":13456,"title":"Change Sublabels for the Name Field","code":"\/**\r\n * Customize name field properties.\r\n *\r\n * @link https:\/\/wpforms.com\/developers\/how-to-change-sublabels-for-the-name-field\/\r\n * \r\n * For support, please visit: https:\/\/www.facebook.com\/groups\/wpformsvip\r\n *\/\r\n \r\nfunction wpf_dev_name_field_properties( $properties, $field, $form_data ) {\r\n \r\n \/\/ Change the text for the sublabel\r\n $properties[ 'inputs' ][ 'first' ][ 'sublabel' ][ 'value' ] = __( 'First Name', 'plugin-domain' );\r\n $properties[ 'inputs' ][ 'middle' ][ 'sublabel' ][ 'value' ] = __( 'Middle Initial', 'plugin-domain' );\r\n $properties[ 'inputs' ][ 'last' ][ 'sublabel' ][ 'value' ] = __( 'Last Name', 'plugin-domain' );\r\n \r\n return $properties;\r\n}\r\n \r\nadd_filter( 'wpforms_field_properties_name' , 'wpf_dev_name_field_properties', 10, 3 );\r\n","note":"Using this snippet will allow you to customize the sublabels that appear under the Name...","categories":["wpforms"],"code_type":"php","needs_auth":false,"tags":[],"max_version":""},{"library_id":13450,"title":"Change Sublabels for the Stripe Credit Card Field","code":"\/**\r\n * Customize Stripe credit card field properties.\r\n *\r\n * @link https:\/\/wpforms.com\/developers\/how-to-change-sublabels-for-the-credit-card-field\r\n * \r\n * For support, please visit: https:\/\/www.facebook.com\/groups\/wpformsvip\r\n *\/\r\n \r\nfunction wpf_dev_creditcard_field_properties( $properties, $field, $form_data ) {\r\n \r\n \/\/ Change sub-label text on the Card Number field\r\n $properties[ 'inputs' ][ 'number' ][ 'sublabel' ][ 'value' ] = __( 'Enter your card number', 'text-domain' );\r\n \r\n \/\/ Change sub-label text on the Card Name field\r\n $properties[ 'inputs' ][ 'name' ][ 'sublabel' ][ 'value' ] = __( 'Name as it appears on the card', 'text-domain' );\r\n \r\n return $properties;\r\n}\r\n \r\nadd_filter( 'wpforms_field_properties_stripe-credit-card' , 'wpf_dev_creditcard_field_properties', 10, 3 );\r\n","note":"With this snippet you can change the sublabels that appear on the Stripe Credit Card...","categories":["wpforms"],"code_type":"php","needs_auth":false,"tags":[],"max_version":""},{"library_id":32161,"title":"Change the No Results Found text in Modern Dropdown","code":"\/**\r\n * Change the No Results Found text in Modern Dropdown.\r\n *\r\n * @link https:\/\/wpforms.com\/developers\/how-to-change-the-no-results-found-text-in-the-modern-dropdown-field\/\r\n *\/\r\n \r\nfunction wpf_dev_change_modern_dropdown_noresults_text( $config, $forms ) {\r\n \r\n \/\/ Change 1369 to an ID of your actual form.\r\n if ( array_key_exists( 1369, $forms ) ) {\r\n \r\n $config[ 'noResultsText' ] = __( 'Apologies, your search term was not found.', 'your-text-domain' );\r\n }\r\n \r\n return $config;\r\n}\r\n \r\nadd_filter( 'wpforms_field_select_choicesjs_config', 'wpf_dev_change_modern_dropdown_noresults_text', 10, 2 );","note":"This snippet changes the default no result found text in Dropdown field with Modern style.","categories":["wpforms"],"code_type":"php","needs_auth":false,"tags":["wpforms"],"max_version":""},{"library_id":32150,"title":"Change the Payment Delimiter Inside Email Notifications","code":"\/**\r\n * Change the payment delimiter in the email notification\r\n *\r\n * @link https:\/\/wpforms.com\/developers\/how-to-change-the-payment-delimiter-inside-email-notifications\/\r\n *\/\r\nfunction wpf_dev_entry_email_data( $fields, $entry, $form_data ) {\r\n \/\/ Only run on my form with ID = 310\r\n if ( absint( $form_data[ 'id' ] ) !== 310 ) {\r\n return $fields;\r\n }\r\n\r\n foreach ( $fields as $field_id => $field ) {\r\n if ( empty( $field[ 'value_choice' ] ) ) {\r\n continue;\r\n }\r\n\r\n \/\/ Default is a dash (-), change here to what you need\r\n $delimiter = ' : ';\r\n\r\n $fields[ $field_id ][ 'value' ] = $field[ 'value_choice' ] . \r\n $delimiter . wpforms_format_amount( $field[ 'amount_raw' ], true );\r\n }\r\n\r\n return $fields;\r\n}\r\nadd_filter( 'wpforms_entry_email_data', 'wpf_dev_entry_email_data', 10, 3 );","note":"This snippet changes the default separator for payment details in emails.","categories":["wpforms"],"code_type":"php","needs_auth":false,"tags":["wpforms"],"max_version":""},{"library_id":6185,"title":"Change the Required Field Indicator","code":"\/**\r\n * Modify the required field indicator\r\n *\r\n * @link https:\/\/wpforms.com\/developers\/how-to-change-required-field-indicator\/\r\n * \r\n * For support, please visit: https:\/\/www.facebook.com\/groups\/wpformsvip\r\n *\/\r\n \r\nfunction wpf_dev_required_indicator( $text ) {\r\n \r\n return ' <span class=\"wpforms-required-label\">' . __( '*', 'wpforms' ) . '<\/span>';\r\n}\r\n \r\nadd_filter( 'wpforms_get_field_required_label', 'wpf_dev_required_indicator', 10, 1 );","note":"Changes the required field indicator. You can set the asterisks symbol to plain text or...","categories":["wpforms"],"code_type":"php","needs_auth":false,"tags":["required-field"],"max_version":""},{"library_id":6179,"title":"Change the Submit Button Color","code":"\/* \r\nChange the color of the submit button\r\nDoc link: https:\/\/wpforms.com\/developers\/how-to-change-the-submit-button-color\/\r\n*\/\r\n\r\n.wpforms-form button[type=submit] {\r\n background-color: #066AAB !important;\r\n border-color: #066AAB !important;\r\n color: #fff !important;\r\n transition: background 0.3s ease-in-out;\r\n}\r\n \r\n.wpforms-form button[type=submit]:hover {\r\n background-color: #04446E !important;\r\n}","note":"Changes the color of the submit button for all WPForms. The colors in this CSS...","categories":["wpforms"],"code_type":"css","needs_auth":false,"tags":["css","styling","submit-button"],"max_version":""},{"library_id":36487,"title":"Change Validation Messages for Required Fields - WPML","code":"\/**\r\n * Customize strings for WPForms form validation \r\n * \r\n * @link https:\/\/wpforms.com\/developers\/change-validation-messages-for-wpml\/\r\n *\/\r\n\r\nfunction wpforms_dev_frontend_strings( $strings ) {\r\n\r\n\t$currentLanguage = defined( 'ICL_LANGUAGE_CODE' ) ? ICL_LANGUAGE_CODE : null;\r\n\r\n\tswitch ( $currentLanguage ) {\r\n\t\tcase 'fr':\r\n\t\t\t$strings[ 'val_required' ] = 'Ce champ est requis.';\r\n\t\t\tbreak;\r\n\t\tcase 'es':\r\n\t\t\t$strings[ 'val_required' ] = 'Este campo es requerido.';\r\n\t\t\tbreak;\r\n\t}\r\n\r\n\treturn $strings;\r\n}\r\n\r\nadd_filter( 'wpforms_frontend_strings', 'wpforms_dev_frontend_strings', 20, 1 );","note":"Below is an example that changes the required field validation message depending on the language...","categories":["wpforms"],"code_type":"php","needs_auth":false,"tags":[],"max_version":""},{"library_id":23130,"title":"Change Validation Messages for WPML","code":"\/**\r\n * Customize strings for WPForms form validation \r\n * \r\n * @link https:\/\/wpforms.com\/developers\/change-validation-messages-for-wpml\/\r\n *\/\r\n \r\nfunction wpforms_dev_frontend_strings( $strings ) {\r\n \r\n$currentLanguage = defined( 'ICL_LANGUAGE_CODE' ) ? ICL_LANGUAGE_CODE : null;\r\n \r\n switch ( $currentLanguage ) {\r\n \r\n \/\/ For French translation\r\n case 'fr':\r\n \r\n \/\/ Required field\r\n $strings[ 'val_required' ] = 'Ce champ est requis.';\r\n \r\n \/\/ Valid Email\r\n $strings[ 'val_email' ] = 'Veuillez entrer une URL valide.';\r\n \r\n \/\/ Email suggestion text\r\n $strings[ 'val_email_suggestion' ] = 'Voulez-vous dire {suggestion}?';\r\n \r\n \/\/ Email restricted text\r\n $strings[ 'val_email_restricted' ] = 'Cette adresse e-mail n\\'est pas autoris\u00e9e.';\r\n \r\n \/\/ Valid number\r\n $strings[ 'val_number' ] = 'S\\'il vous plait, entrez un nombre valide.';\r\n \r\n \/\/ Valid positive number\r\n $strings[ 'val_number_positive' ] = 'Veuillez entrer un nombre positif valide.';\r\n \r\n \/\/ Confirmation message 'fields do not match'\r\n $strings[ 'val_confirm' ] = 'Les valeurs de champ ne correspondent pas.';\r\n \r\n \/\/ Valid input mask incomplete\r\n $strings[ 'val_inputmask_incomplete' ] = 'Veuillez remplir le champ au format requis.';\r\n \r\n \/\/ Checkbox option limit\r\n $strings[ 'val_checklimit' ] = 'Vous avez d\u00e9pass\u00e9 le nombre de s\u00e9lections autoris\u00e9es: {#}.';\r\n \r\n \/\/ Character limit\r\n $strings[ 'val_limit_characters' ] = 'La limite est de {limit} caract\u00e8res. Caract\u00e8res restants : {remaining}.';\r\n \r\n \/\/ Word limit\r\n $strings[ 'val_limit_words' ] = 'La limite est de {limit} mots. Mots restant : {restant}.';\r\n \r\n \/\/ Valid URL\r\n $strings[ 'val_url' ] = 'Veuillez saisir une URL valide.';\r\n \r\n \/\/ All phone field - Smart, International and US\r\n $strings [ 'val_phone' ] = 'Veuillez fournir un num\u00e9ro de t\u00e9l\u00e9phone valide.';\r\n \r\n \/\/ Valid file extension\r\n $strings[ 'val_fileextension' ] = 'Le type de fichier n\\'est pas autoris\u00e9.';\r\n \r\n \/\/ File max size limit text\r\n $strings[ 'val_filesize' ] = 'Le fichier d\u00e9passe la taille maximale autoris\u00e9e.';\r\n \r\n \/\/ Number of files upload limit text\r\n $strings[ 'maxfilenumber' ] = 'Les t\u00e9l\u00e9chargements de fichiers d\u00e9passent le nombre maximum autoris\u00e9 ({fileLimit}).';\r\n \r\n \/\/ Valid 12h time format\r\n $strings[ 'val_time12h' ] = 'Veuillez entrer l\\'heure au format 12 heures AM \/ PM (par exemple, 8h45)';\r\n \r\n \/\/ Valid 24h time format\r\n $strings[ 'val_time24h' ] = 'Veuillez entrer l\\'heure au format 24 heures (par exemple, 22h45).';\r\n \r\n \/\/ Limit hours text 'Please enter time between...'\r\n $strings[ 'val_time_limit' ] = 'Veuillez saisir une dur\u00e9e comprise entre {minTime} et {maxTime}.';\r\n \r\n \/\/ Payment required text\r\n $strings[ 'val_requiredpayment' ] = 'Le paiement est requis.';\r\n \r\n \/\/ Valid credit card number\r\n $strings[ 'val_creditcard' ] = 'Veuillez entrer un num\u00e9ro de carte de cr\u00e9dit valide.';\r\n \r\n \/\/ Maximum size limit reached text\r\n $strings[ 'val_post_max_size' ] = 'La taille totale des fichiers s\u00e9lectionn\u00e9s {totalSize} Mo d\u00e9passe la limite autoris\u00e9e {maxSize} Mo.';\r\n \r\n \/\/ Password strength text\r\n $strings[ 'val_password_strength' ] = 'Un mot de passe plus fort est requis. Envisagez d\\'utiliser des lettres majuscules et minuscules, des chiffres et des symboles.';\r\n \r\n \/\/ Valid unique value required\r\n $strings[ 'val_unique' ] = 'La valeur doit \u00eatre unique.';\r\n \r\n \/\/ reCAPTCHA failed message text\r\n $strings[ 'val_recaptcha_fail_msg' ] = 'La v\u00e9rification Google reCAPTCHA a \u00e9chou\u00e9, veuillez r\u00e9essayer plus tard.';\r\n \r\n break;\r\n \r\n \/\/ For Spanish translation\r\n case 'es':\r\n \r\n \/\/ Required field\r\n $strings[ 'val_required' ] = 'Este campo es requerido.';\r\n \r\n \/\/ Valid Email\r\n $strings[ 'val_email' ] = 'Por favor, introduce una direcci\u00f3n de correo electr\u00f3nico v\u00e1lida.';\r\n \r\n \/\/ Email suggestion text\r\n $strings[ 'val_email_suggestion' ] = '\u00bfQuiso decir {sugerencia}?';\r\n \r\n \/\/ Email Restricted\r\n $strings[ 'val_email_restricted' ] = 'Esta direcci\u00f3n de correo electr\u00f3nico no est\u00e1 permitida.';\r\n \r\n \/\/ Valid number\r\n $strings[ 'val_number' ] = 'Por favor ingrese un n\u00famero valido.';\r\n \r\n \/\/ Valid positive number\r\n $strings[ 'val_number_positive' ] = 'Introduzca un n\u00famero positivo v\u00e1lido.';\r\n \r\n \/\/ Confirmation message 'fields do not match'\r\n $strings[ 'val_confirm' ] = 'Los valores de campo no coinciden.';\r\n \r\n \/\/ Valid input mask incomplete text\r\n $strings[ 'val_inputmask_incomplete' ] = 'Por favor llene el campo en el formato requerido.';\r\n \r\n \/\/ Checkbox option limit\r\n $strings[ 'val_checklimit' ] = 'Ha excedido el n\u00famero de selecciones permitidas: {#}.';\r\n \r\n \/\/ Character limit\r\n $strings[ 'val_limit_characters' ] = 'El l\u00edmite es {l\u00edmite} caracteres. Caracteres restantes: {restante}.';\r\n \r\n \/\/ Word limit\r\n $strings[ 'val_limit_words' ] = 'El l\u00edmite es {l\u00edmite} palabras. Palabras restantes: {restante}.';\r\n \r\n \/\/ Valid URL\r\n $strings[ 'val_url' ] = 'Por favor introduzca un URL v\u00e1lido.';\r\n \r\n \/\/ All phone field - Smart, International and US\r\n $strings[ 'val_phone' ] = 'Por favor forne\u00e7a um n\u00famero de telefone v\u00e1lido.';\r\n \r\n \/\/ Valid file type\r\n $strings[ 'val_fileextension' ] = 'El tipo de archivo no est\u00e1 permitido.';\r\n \r\n \/\/ Max size limit text\r\n $strings[ 'val_filesize' ] = 'El archivo excede el tama\u00f1o m\u00e1ximo permitido.';\r\n \r\n \/\/ Number of files upload limit text\r\n $strings[ 'maxfilenumber' ] = 'Las cargas de archivos superan el n\u00famero m\u00e1ximo permitido ({fileLimit}).';\r\n \r\n \/\/ Valid 12h time format\r\n $strings[ 'val_time12h' ] = 'Ingrese la hora en formato AM \/ PM de 12 horas (por ejemplo, 8:45 AM).';\r\n \r\n \/\/ Valid 24h time format\r\n $strings[ 'val_time24h' ] = 'Ingrese la hora en formato de 24 horas (por ejemplo, 22:45).';\r\n \r\n \/\/ Limit hours text 'Please enter time between...'\r\n $strings[ 'val_time_limit' ] = 'Ingrese el tiempo entre {minTime} y {maxTime}.';\r\n \r\n \/\/ Payment required text\r\n $strings[ 'val_requiredpayment' ] = 'Se requiere pago.';\r\n \r\n \/\/ Valid credit card number\r\n $strings[ 'val_creditcard' ] = 'Por favor, introduzca un n\u00famero de tarjeta de cr\u00e9dito v\u00e1lida.';\r\n \r\n \/\/ Maximum size limit reached text\r\n $strings[ 'val_post_max_size' ] = 'El tama\u00f1o total de los archivos seleccionados {totalSize} Mb excede el l\u00edmite permitido {maxSize} Mb.';\r\n \r\n \/\/ Password strength text\r\n $strings[ 'val_password_strength' ] = 'Se requiere una contrase\u00f1a m\u00e1s fuerte. Considere el uso de letras may\u00fasculas y min\u00fasculas, n\u00fameros y s\u00edmbolos.';\r\n \r\n \/\/ Valid unique value required\r\n $strings[ 'val_unique' ] = 'El valor debe ser \u00fanico.';\r\n \r\n \/\/ reCAPTCHA failed message text\r\n $strings[ 'val_recaptcha_fail_msg' ] = 'La verificaci\u00f3n de Google reCAPTCHA fall\u00f3, int\u00e9ntalo de nuevo m\u00e1s tarde.';\r\n \r\n break;\r\n }\r\n \r\nreturn $strings;\r\n \r\n}\r\n \r\nadd_filter( 'wpforms_frontend_strings', 'wpforms_dev_frontend_strings', 20, 1 );\r\n","note":"When you need to provide multiple different language translations, these messages need to be conditionally...","categories":["wpforms"],"code_type":"php","needs_auth":false,"tags":[],"max_version":""},{"library_id":31487,"title":"Changing sublabels for Email Field on a Single Form","code":"\/**\r\n * Customize email field properties.\r\n *\r\n * @link https:\/\/wpforms.com\/developers\/how-to-change-sublabels-for-the-email-field\/\r\n *\/\r\n\r\nfunction wpf_dev_email_field_properties( $properties, $field, $form_data ) {\r\n\r\n\t\/\/ Only process this snippet on the form ID 123\r\n if ( absint( $form_data[ 'id' ] ) !== 123 ) {\r\n\r\n return $properties;\r\n } \r\n\r\n \/\/ Change sublabel values\r\n $properties[ 'inputs' ][ 'primary' ][ 'sublabel' ][ 'value' ] = __( 'Enter Your Email', 'plugin-domain' );\r\n $properties[ 'inputs' ][ 'secondary' ][ 'sublabel' ][ 'value' ] = __( 'To confirm, re-enter your email address here', 'plugin-domain' );\r\n\r\n return $properties;\r\n\r\n}\r\n\r\nadd_filter( 'wpforms_field_properties_email' , 'wpf_dev_email_field_properties', 10, 3 );","note":"This snippet is used to change sublabel for Email field on a specific form. Be...","categories":["wpforms"],"code_type":"php","needs_auth":false,"tags":[],"max_version":""},{"library_id":31484,"title":"Changing Sublabels for the Email Field","code":"\/**\r\n * Customize email field properties.\r\n *\r\n * @link https:\/\/wpforms.com\/developers\/how-to-change-sublabels-for-the-email-field\/\r\n *\/\r\n\r\nfunction wpf_dev_email_field_properties( $properties, $field, $form_data ) {\r\n\r\n \/\/ Change sublabel values\r\n $properties[ 'inputs' ][ 'primary' ][ 'sublabel' ][ 'value' ] = __( 'Enter Your Email', 'plugin-domain' );\r\n $properties[ 'inputs' ][ 'secondary' ][ 'sublabel' ][ 'value' ] = __( 'To confirm, re-enter your email address here', 'plugin-domain' );\r\n\r\n return $properties;\r\n\r\n}\r\n\r\nadd_filter( 'wpforms_field_properties_email' , 'wpf_dev_email_field_properties', 10, 3 );","note":"This snippet is used to update the default labels for the Email field when it...","categories":["wpforms"],"code_type":"php","needs_auth":false,"tags":[],"max_version":""},{"library_id":33043,"title":"Changing the Cache Time on Your Form Token","code":"\/**\r\n * Extend cache time on form tokens before today.\r\n *\r\n * @link https:\/\/wpforms.com\/developers\/how-to-change-the-cache-time-on-your-form-token\r\n *\/\r\n \r\nfunction example_add_longer_token_time_before( $times ) {\r\n \/\/ Allow the token to persist for 3, 4, and 5 days\r\n $times[] = 3 * DAY_IN_SECONDS;\r\n $times[] = 4 * DAY_IN_SECONDS;\r\n $times[] = 5 * DAY_IN_SECONDS;\r\n \r\n return $times;\r\n}\r\nadd_filter( 'wpforms_form_token_check_before_today', 'example_add_longer_token_time_before' );\r\n \r\n\/**\r\n * Extend cache time on form tokens before today.\r\n *\r\n * @link https:\/\/wpforms.com\/developers\/how-to-change-the-cache-time-on-your-form-token\r\n *\/\r\n \r\nfunction example_add_longer_token_time_after( $times ) {\r\n \/\/ Allow the token to persist for 1 day\r\n $times[] = DAY_IN_SECONDS;\r\n \r\n return $times;\r\n}\r\nadd_filter( 'wpforms_form_token_check_after_today', 'example_add_longer_token_time_after' );\r\n","note":"","categories":["wpforms"],"code_type":"php","needs_auth":false,"tags":["wpforms"],"max_version":""},{"library_id":40964,"title":"Changing the Name Attribute of a Hidden Field","code":"\/**\r\n * Custom function to change the name attribute of hidden fields in any form.\r\n *\r\n * @link https:\/\/wpforms.com\/developers\/how-to-change-the-name-attribute-of-a-hidden-field\/\r\n *\/\r\n\r\nfunction wpf_field_properties_hidden( $properties, $field, $form_data ) {\r\n \r\n \/\/ Optional, you can limit to specific forms. Below, we restrict output to only the form #1000.\r\n if ( absint( $form_data[ 'id' ] ) !== 1000 ) {\r\n return;\r\n }\r\n \r\n \/\/ Look for the name attribute and set the name attribute to custom_name_hidden_field\r\n $properties[ 'inputs' ][ 'primary' ][ 'attr' ][ 'name' ] = 'custom_name_hidden_field';\r\n\r\n return $properties;\r\n}\r\nadd_filter( 'wpforms_field_properties_hidden', 'wpf_field_properties_hidden', 10, 3 );","note":"This code snippet can be used to change the Name attribute of a Hidden field.","categories":["wpforms"],"code_type":"php","needs_auth":false,"tags":["wpforms"],"max_version":""},{"library_id":30091,"title":"Conditionally Show the Submit Button","code":"\/**\r\n * Conditionally show the submit button\r\n *\r\n * @link https:\/\/wpforms.com\/developers\/how-to-conditionally-show-the-submit-button\/\r\n *\/\r\n \r\nadd_action( 'wp_head', function () { ?>\r\n \r\n <style>\r\n \r\n \/* CSS hide submit button on page load *\/\r\n #wpforms-form-1000 .wpforms-submit-container .wpforms-submit {\r\n visibility:hidden;\r\n }\r\n \r\n #wpforms-form-1000 .wpforms-submit-container .wpforms-submit.show-submit {\r\n visibility:visible;\r\n }\r\n \r\n <\/style>\r\n \r\n<?php } );\r\n \r\n \r\n\/\/ Conditional logic for Submit button\r\nfunction wpf_dev_form_redirect() {\r\n ?>\r\n <script>\r\n jQuery(function($){\r\n $( \"form#wpforms-form-1000\" ).click(function(){\r\n var selectedval = $( \".wpforms-form input[type='radio']:checked\" ).val();\r\n if(selectedval == \"No\"){\r\n window.location = \"\/thank-you\";\r\n }\r\n if(selectedval == \"Yes\"){\r\n $( \".wpforms-submit\" ).addClass( \"show-submit\" );\r\n }\r\n });\r\n });\r\n <\/script>\r\n <?php\r\n}\r\nadd_action( 'wpforms_wp_footer_end', 'wpf_dev_form_redirect', 10 );","note":"This snippet will automatically show or hide the Submit button based on form field responses.","categories":["wpforms"],"code_type":"php","needs_auth":false,"tags":[],"max_version":""},{"library_id":19071,"title":"Create a Smart Tag for the Current Time","code":"\/**\r\n * Create a custom Smart Tag \r\n \r\n Original doc link: https:\/\/wpforms.com\/developers\/how-to-create-a-smart-tag-for-the-current-time\/\r\n\r\n For support, please visit: https:\/\/www.facebook.com\/groups\/wpformsvip\r\n *\/\r\n \r\nfunction wpf_dev_register_smarttag( $tags ) {\r\n \r\n \/\/ Key is the tag, item is the tag name.\r\n $tags[ 'current_time' ] = 'Current Time';\r\n \r\n return $tags;\r\n}\r\n \r\nadd_filter( 'wpforms_smart_tags', 'wpf_dev_register_smarttag' );\r\n \r\n \r\n\/**\r\n * Process the Smart Tag.\r\n *\r\n * @link https:\/\/wpforms.com\/developers\/how-to-create-a-smart-tag-for-the-current-time\r\n *\/\r\n \r\nfunction wpf_dev_process_smarttag( $content, $tag ) {\r\n \r\n \/\/ Only run if it is our desired tag.\r\n if ( 'current_time' === $tag ) {\r\n \r\n date_default_timezone_set( 'US\/Eastern' );\r\n \r\n $link = date( 'h:i:s A' );\r\n \r\n \/\/ Replace the tag with our link.\r\n $content = str_replace( '{current_time}', $link, $content );\r\n }\r\n \r\n return $content;\r\n}\r\n \r\nadd_filter( 'wpforms_smart_tag_process', 'wpf_dev_process_smarttag', 10, 2 );\r\n","note":"This snippet will create a new Smart Tag for you that you can use anywhere...","categories":["wpforms"],"code_type":"php","needs_auth":false,"tags":[],"max_version":""},{"library_id":23363,"title":"Create Additional Formats for the Date Field","code":"\/* \r\nAdd additional formats for the Date field Date Picker. \r\n\r\nOriginal doc link: https:\/\/wpforms.com\/developers\/how-to-create-additional-formats-for-the-date-field\/\r\n\r\nFor support, please visit: https:\/\/www.facebook.com\/groups\/wpformsvip\r\n*\/\r\n \r\nfunction wpf_dev_date_field_formats( $formats ) {\r\n \r\n \/\/ Item key is JS date character - see https:\/\/flatpickr.js.org\/formatting\/\r\n \/\/ Item value is in PHP format - see http:\/\/php.net\/manual\/en\/function.date.php\r\n \r\n \/\/ Adds new format Monday, 20th of December 2021\r\n $formats[ 'l, J \\of F Y' ] = 'l, jS \\of F Y';\r\n\t$formats[ 'l, J F Y' ] = 'l, jS F Y';\r\n\t$formats[ 'j-m-y' ] = 'j-m-y';\r\n \r\n return $formats;\r\n}\r\n \r\nadd_filter( 'wpforms_datetime_date_formats', 'wpf_dev_date_field_formats', 10, 1 );","note":"Add custom date formats to the Date field in WPForms.","categories":["wpforms"],"code_type":"php","needs_auth":false,"tags":[],"max_version":""},{"library_id":13431,"title":"Create Additional Schemes for the Address Field","code":"\/**\r\n * WPForms Add new address field scheme (Canada)\r\n *\r\n * @link https:\/\/wpforms.com\/developers\/create-additional-schemes-for-the-address-field\/\r\n * \r\n * For support, please visit: https:\/\/www.facebook.com\/groups\/wpformsvip\r\n *\/\r\n \r\nfunction wpf_dev_new_address_scheme( $schemes ) {\r\n \r\n $schemes[ 'canada' ] = array(\r\n 'label' => 'Canada',\r\n 'address1_label' => 'Address Line 1',\r\n 'address2_label' => 'Address Line 2',\r\n 'city_label' => 'City',\r\n 'postal_label' => 'Code Postal',\r\n 'state_label' => 'Province',\r\n 'states' => array(\r\n 'BC' => 'British Columbia',\r\n 'ON' => 'Ontario',\r\n 'QC' => 'Quebec',\r\n 'AB' => 'Alberta',\r\n 'MB' => 'Manitoba',\r\n 'NB' => 'New Brunswick',\r\n 'NL' => 'Newfoundland and Labrador',\r\n 'NT' => 'Northwest Territories',\r\n 'NS' => 'Nova Scotia',\r\n 'NU' => 'Nunavut',\r\n 'PE' => 'Prince Edward Island',\r\n 'SK' => 'Saskatchewan',\r\n 'YT' => 'Yukon',\r\n ),\r\n );\r\n \r\n return $schemes;\r\n \r\n}\r\n \r\nadd_filter( 'wpforms_address_schemes', 'wpf_dev_new_address_scheme', 10, 1);\r\n","note":"This snippet will show you how to create your own Scheme for the Address field....","categories":["wpforms"],"code_type":"php","needs_auth":false,"tags":[],"max_version":""},{"library_id":32145,"title":"Create Custom Address Scheme","code":"\/**\r\n * WPForms Add new address field scheme (Custom)\r\n *\r\n * @link https:\/\/wpforms.com\/developers\/create-additional-schemes-for-the-address-field\/\r\n *\/\r\n \r\nfunction wpf_new_address_scheme( $schemes ) {\r\n \r\n $schemes[ 'custom' ] = array(\r\n 'label' => 'Custom',\r\n 'address1_label' => 'Address Line 1',\r\n 'address2_label' => 'Address Line 2',\r\n 'city_label' => 'City',\r\n 'postal_label' => 'Postal Code',\r\n 'state_label' => 'State \/ Province \/ Region',\r\n 'states' => '',\r\n 'countries' => array(\r\n 'AF' => 'Afghanistan',\r\n 'AX' => 'Aland Islands',\r\n 'AL' => 'Albania',\r\n 'DZ' => 'Algeria',\r\n 'AS' => 'American Samoa',\r\n 'AD' => 'Andorra',\r\n 'AO' => 'Angola',\r\n 'AI' => 'Anguilla',\r\n 'AQ' => 'Antarctica',\r\n 'AG' => 'Antigua and Barbuda',\r\n 'AR' => 'Argentina',\r\n 'AM' => 'Armenia',\r\n 'AW' => 'Aruba',\r\n 'AC' => 'Ascension Island',\r\n 'AU' => 'Australia',\r\n 'AT' => 'Austria',\r\n 'AZ' => 'Azerbaijan',\r\n 'BS' => 'Bahamas',\r\n 'BH' => 'Bahrain',\r\n 'BD' => 'Bangladesh',\r\n 'BB' => 'Barbados',\r\n 'BY' => 'Belarus',\r\n 'BE' => 'Belgium',\r\n 'BZ' => 'Belize',\r\n 'BJ' => 'Benin',\r\n 'BM' => 'Bermuda',\r\n 'BT' => 'Bhutan',\r\n 'BO' => 'Bolivia',\r\n 'BA' => 'Bosnia and Herzegovina',\r\n 'BW' => 'Botswana',\r\n 'BV' => 'Bouvet Island',\r\n 'BR' => 'Brazil',\r\n 'IO' => 'British Indian Ocean Territory',\r\n 'VG' => 'British Virgin Islands',\r\n 'BN' => 'Brunei',\r\n 'BG' => 'Bulgaria',\r\n 'BF' => 'Burkina Faso',\r\n 'BI' => 'Burundi',\r\n 'KH' => 'Cambodia',\r\n 'CM' => 'Cameroon',\r\n 'CA' => 'Canada',\r\n 'IC' => 'Canary Islands',\r\n 'CV' => 'Cape Verde',\r\n 'BQ' => 'Caribbean Netherlands',\r\n 'KY' => 'Cayman Islands',\r\n 'CF' => 'Central African Republic',\r\n 'EA' => 'Ceuta and Melilla',\r\n 'TD' => 'Chad',\r\n 'CL' => 'Chile',\r\n 'CN' => 'China',\r\n 'CX' => 'Christmas Island',\r\n 'CP' => 'Clipperton Island',\r\n 'CC' => 'Cocos (Keeling) Islands',\r\n 'CO' => 'Colombia',\r\n 'KM' => 'Comoros',\r\n 'CD' => 'Congo (DRC)',\r\n 'CG' => 'Congo (Republic)',\r\n 'CK' => 'Cook Islands',\r\n 'CR' => 'Costa Rica',\r\n 'CI' => 'C\u00f4te d\u2019Ivoire',\r\n 'HR' => 'Croatia',\r\n 'CU' => 'Cuba',\r\n 'CW' => 'Cura\u00e7ao',\r\n 'CY' => 'Cyprus',\r\n 'CZ' => 'Czech Republic',\r\n 'DK' => 'Denmark (Danmark)',\r\n 'DG' => 'Diego Garcia',\r\n 'DJ' => 'Djibouti',\r\n 'DM' => 'Dominica',\r\n 'DO' => 'Dominican Republic',\r\n 'EC' => 'Ecuador',\r\n 'EG' => 'Egypt',\r\n 'SV' => 'El Salvador',\r\n 'GQ' => 'Equatorial Guinea',\r\n 'ER' => 'Eritrea',\r\n 'EE' => 'Estonia',\r\n 'ET' => 'Ethiopia',\r\n 'FK' => 'Falkland Islands',\r\n 'FO' => 'Faroe Islands',\r\n 'FJ' => 'Fiji',\r\n 'FI' => 'Finland',\r\n 'FR' => 'France',\r\n 'GF' => 'French Guiana',\r\n 'PF' => 'French Polynesia',\r\n 'TF' => 'French Southern Territories',\r\n 'GA' => 'Gabon',\r\n 'GM' => 'Gambia',\r\n 'GE' => 'Georgia',\r\n 'DE' => 'Germany',\r\n 'GH' => 'Ghana',\r\n 'GI' => 'Gibraltar',\r\n 'GR' => 'Greece',\r\n 'GL' => 'Greenland',\r\n 'GD' => 'Grenada',\r\n 'GP' => 'Guadeloupe',\r\n 'GU' => 'Guam',\r\n 'GT' => 'Guatemala',\r\n 'GG' => 'Guernsey',\r\n 'GN' => 'Guinea',\r\n 'GW' => 'Guinea-Bissau',\r\n 'GY' => 'Guyana',\r\n 'HT' => 'Haiti',\r\n 'HM' => 'Heard & McDonald Islands',\r\n 'HN' => 'Honduras',\r\n 'HK' => 'Hong Kong',\r\n 'HU' => 'Hungary',\r\n 'IS' => 'Iceland',\r\n 'IN' => 'India',\r\n 'ID' => 'Indonesia',\r\n 'IR' => 'Iran',\r\n 'IQ' => 'Iraq',\r\n 'IE' => 'Ireland',\r\n 'IM' => 'Isle of Man',\r\n 'IL' => 'Israel',\r\n 'IT' => 'Italy',\r\n 'JM' => 'Jamaica',\r\n 'JP' => 'Japan',\r\n 'JE' => 'Jersey',\r\n 'JO' => 'Jordan',\r\n 'KZ' => 'Kazakhstan',\r\n 'KE' => 'Kenya',\r\n 'KI' => 'Kiribati',\r\n 'XK' => 'Kosovo',\r\n 'KW' => 'Kuwait',\r\n 'KG' => 'Kyrgyzstan',\r\n 'LA' => 'Laos',\r\n 'LV' => 'Latvia',\r\n 'LB' => 'Lebanon',\r\n 'LS' => 'Lesotho',\r\n 'LR' => 'Liberia',\r\n 'LY' => 'Libya',\r\n 'LI' => 'Liechtenstein',\r\n 'LT' => 'Lithuania',\r\n 'LU' => 'Luxembourg',\r\n 'MO' => 'Macau',\r\n 'MK' => 'Macedonia (FYROM)',\r\n 'MG' => 'Madagascar',\r\n 'MW' => 'Malawi',\r\n 'MY' => 'Malaysia',\r\n 'MV' => 'Maldives',\r\n 'ML' => 'Mali',\r\n 'MT' => 'Malta',\r\n 'MH' => 'Marshall Islands',\r\n 'MQ' => 'Martinique',\r\n 'MR' => 'Mauritania',\r\n 'MU' => 'Mauritius',\r\n 'YT' => 'Mayotte',\r\n 'MX' => 'Mexico',\r\n 'FM' => 'Micronesia',\r\n 'MD' => 'Moldova',\r\n 'MC' => 'Monaco',\r\n 'MN' => 'Mongolia',\r\n 'ME' => 'Montenegro',\r\n 'MS' => 'Montserrat',\r\n 'MA' => 'Morocco',\r\n 'MZ' => 'Mozambique',\r\n 'MM' => 'Myanmar',\r\n 'NA' => 'Namibia',\r\n 'NR' => 'Nauru',\r\n 'NP' => 'Nepal',\r\n 'NL' => 'Netherlands',\r\n 'NC' => 'New Caledonia',\r\n 'NZ' => 'New Zealand',\r\n 'NI' => 'Nicaragua',\r\n 'NE' => 'Niger',\r\n 'NG' => 'Nigeria',\r\n 'NU' => 'Niue',\r\n 'NF' => 'Norfolk Island',\r\n 'MP' => 'Northern Mariana Islands',\r\n 'KP' => 'North Korea',\r\n 'NO' => 'Norway',\r\n 'OM' => 'Oman',\r\n 'PK' => 'Pakistan',\r\n 'PW' => 'Palau',\r\n 'PS' => 'Palestine',\r\n 'PA' => 'Panama',\r\n 'PG' => 'Papua New Guinea',\r\n 'PY' => 'Paraguay',\r\n 'PE' => 'Peru',\r\n 'PH' => 'Philippines',\r\n 'PN' => 'Pitcairn Islands',\r\n 'PL' => 'Poland',\r\n 'PT' => 'Portugal',\r\n 'PR' => 'Puerto Rico',\r\n 'QA' => 'Qatar',\r\n 'RE' => 'R\u00e9union',\r\n 'RO' => 'Romania',\r\n 'RU' => 'Russia',\r\n 'RW' => 'Rwanda',\r\n 'BL' => 'Saint Barth\u00e9lemy',\r\n 'SH' => 'Saint Helena',\r\n 'KN' => 'Saint Kitts and Nevis',\r\n 'LC' => 'Saint Lucia',\r\n 'MF' => 'Saint Martin',\r\n 'PM' => 'Saint Pierre and Miquelon',\r\n 'WS' => 'Samoa',\r\n 'SM' => 'San Marino',\r\n 'ST' => 'S\u00e3o Tom\u00e9 and Pr\u00edncipe',\r\n 'SA' => 'Saudi Arabia',\r\n 'SN' => 'Senegal',\r\n 'RS' => 'Serbia',\r\n 'SC' => 'Seychelles',\r\n 'SL' => 'Sierra Leone',\r\n 'SG' => 'Singapore',\r\n 'SX' => 'Sint Maarten',\r\n 'SK' => 'Slovakia',\r\n 'SI' => 'Slovenia',\r\n 'SB' => 'Solomon Islands',\r\n 'SO' => 'Somalia',\r\n 'ZA' => 'South Africa',\r\n 'GS' => 'South Georgia & South Sandwich Islands',\r\n 'KR' => 'South Korea',\r\n 'SS' => 'South Sudan',\r\n 'ES' => 'Spain',\r\n 'LK' => 'Sri Lanka',\r\n 'VC' => 'St. Vincent & Grenadines',\r\n 'SD' => 'Sudan',\r\n 'SR' => 'Suriname',\r\n 'SJ' => 'Svalbard and Jan Mayen',\r\n 'SZ' => 'Swaziland',\r\n 'SE' => 'Sweden',\r\n 'CH' => 'Switzerland',\r\n 'SY' => 'Syria',\r\n 'TW' => 'Taiwan, Province of China',\r\n 'TJ' => 'Tajikistan',\r\n 'TZ' => 'Tanzania',\r\n 'TH' => 'Thailand',\r\n 'TL' => 'Timor-Leste',\r\n 'TG' => 'Togo',\r\n 'TK' => 'Tokelau',\r\n 'TO' => 'Tonga',\r\n 'TT' => 'Trinidad and Tobago',\r\n 'TA' => 'Tristan da Cunha',\r\n 'TN' => 'Tunisia',\r\n 'TR' => 'Turkey',\r\n 'TM' => 'Turkmenistan',\r\n 'TC' => 'Turks and Caicos Islands',\r\n 'TV' => 'Tuvalu',\r\n 'UM' => 'U.S. Outlying Islands',\r\n 'VI' => 'U.S. Virgin Islands',\r\n 'UG' => 'Uganda',\r\n 'UA' => 'Ukraine',\r\n 'AE' => 'United Arab Emirates',\r\n 'GB' => 'United Kingdom',\r\n 'US' => 'United States of America',\r\n 'UY' => 'Uruguay',\r\n 'UZ' => 'Uzbekistan',\r\n 'VU' => 'Vanuatu',\r\n 'VA' => 'Vatican City',\r\n 'VE' => 'Venezuela',\r\n 'VN' => 'Vietnam',\r\n 'WF' => 'Wallis and Futuna',\r\n 'EH' => 'Western Sahara',\r\n 'YE' => 'Yemen',\r\n 'ZM' => 'Zambia',\r\n 'ZW' => 'Zimbabwe',\r\n ),\r\n );\r\n \r\n return $schemes;\r\n \r\n}\r\n \r\nadd_filter( 'wpforms_address_schemes', 'wpf_new_address_scheme', 10, 1 );","note":"This code snippet will create your own unique address scheme and list all the countries.","categories":["wpforms"],"code_type":"php","needs_auth":false,"tags":["wpforms"],"max_version":""},{"library_id":33512,"title":"Creating a Form With Floating Labels","code":"form#wpforms-form-1682 {\r\n position: relative;\r\n}\r\nform#wpforms-form-1682 .floating label:nth-of-type(2) {\r\n display: none;\r\n}\r\n.floating input {\r\n position: relative;\r\n min-height: 65px;\r\n padding: 15px 10px 10px 15px !important;\r\n}\r\n.floating textarea {\r\n position: relative;\r\n min-height: 200px;\r\n padding: 35px 15px 15px 15px !important;\r\n}\r\n.floating input + label {\r\n position: relative !important;\r\n top: -50px !important;\r\n padding: 15px 0 0 15px !important;\r\n opacity: .5;\r\n font-size: 12px !important;\r\n transition: all .5s ease-in-out 0s;\r\n}\r\n.floating textarea + label {\r\n position: relative !important;\r\n top: -200px !important;\r\n padding: 35px 15px 15px 15px !important;\r\n opacity: .5;\r\n font-size: 12px !important;\r\n transition: all .5s ease-in-out 0s;\r\n}\r\n.floating input:focus + label, .floating input:not(:placeholder-shown) + label {\r\n top: -70px !important;\r\n opacity: 1;\r\n}\r\n.floating textarea:focus + label, .floating textarea:not(:placeholder-shown) + label {\r\n top: -220px !important;\r\n opacity: 1;\r\n}\r\n.floating.wpforms-has-error em.wpforms-error {\r\n position: relative;\r\n top: -50px;\r\n left: 10px;\r\n}\r\n.wpforms-field-textarea.floating.wpforms-has-error em.wpforms-error {\r\n position: relative;\r\n top: -190px;\r\n left: 10px;\r\n}\r\n.floating.wpforms-has-error label {\r\n display: none;\r\n}\r\n.floating ::-webkit-input-placeholder { \/* Chrome and Safari *\/\r\n color: transparent !important;\r\n}\r\n.floating :-moz-placeholder { \/* Mozilla Firefox 4 to 18 *\/\r\n color: transparent !important;\r\n}\r\n \r\n.floating ::-moz-placeholder { \/* Mozilla Firefox 19+ *\/\r\n color: transparent !important;\r\n}\r\n \r\n.floating :-ms-input-placeholder { \/* Internet Explorer 10-11 *\/\r\n color: transparent !important;\r\n}\r\n \r\n.floating ::-ms-input-placeholder { \/* Microsoft Edge *\/\r\n color: transparent !important;\r\n}","note":"","categories":["wpforms"],"code_type":"css","needs_auth":false,"tags":[],"max_version":""},{"library_id":33508,"title":"Creating a Smart Tag from an ACF Field","code":"\/**\r\n * Register the Smart Tag so it will be available to select in the form builder.\r\n *\r\n * @link https:\/\/wpforms.com\/developers\/how-to-create-a-smart-tag-from-an-acf-field\/\r\n *\/\r\n \r\nfunction wpf_dev_register_smarttag( $tags ) {\r\n \r\n \/\/ Key is the tag, item is the tag name.\r\n $tags[ 'portfolio_price' ] = 'Portfolio Price';\r\n \r\n return $tags;\r\n}\r\n \r\nadd_filter( 'wpforms_smart_tags', 'wpf_dev_register_smarttag' );\r\n \r\n\/**\r\n * Process the Smart Tag.\r\n *\r\n * @link https:\/\/wpforms.com\/developers\/how-to-create-a-smart-tag-from-an-acf-field\/\r\n *\/\r\n \r\nfunction wpf_dev_process_smarttag( $content, $tag ) {\r\n \r\n \/\/ Only run if it is our desired tag.\r\n if ( 'portfolio_price' === $tag ) {\r\n \r\n \/\/Get the field name from ACF\r\n $my_acf_field = get_field( 'portfolio_price', get_the_ID() );\r\n \r\n \/\/ Replace the tag with our link.\r\n $content = str_replace( '{portfolio_price}', $my_acf_field, $content );\r\n }\r\n \r\n return $content;\r\n}\r\n \r\nadd_filter( 'wpforms_smart_tag_process', 'wpf_dev_process_smarttag', 10, 2 );","note":"","categories":["wpforms"],"code_type":"php","needs_auth":false,"tags":[],"max_version":""},{"library_id":31495,"title":"Creating Additional Format for the Date \/ Time field","code":"\/**\r\n * Add additional formats for the Time field Format dropdown.\r\n *\r\n * @link https:\/\/wpforms.com\/developers\/how-to-create-additional-formats-for-the-date-time-field-time-picker\/\r\n *\/\r\n\r\nfunction wpf_dev_date_field_time_formats1 ( $time_formats ) {\r\n\r\n \/\/ Displays 2-digit hour, 2-digit minute, and 2-digit seconds\r\n\t$time_formats[ 'H:i:s' ] = 'HH:MM:SS';\r\n\r\n\treturn $time_formats;\r\n}\r\nadd_filter( 'wpforms_datetime_time_formats', 'wpf_dev_date_field_time_formats1', 10, 1 );","note":"This snippet is used to add extra formats for the Time interval on the Date...","categories":["wpforms"],"code_type":"php","needs_auth":false,"tags":[],"max_version":""},{"library_id":22950,"title":"Creating Multi-Column Form Layouts With CSS Classes","code":"\/* \r\nMulti-column layout with conditional fields\r\n\r\nOriginal doc link: https:\/\/wpforms.com\/docs\/how-to-create-multi-column-form-layouts-in-wpforms\/\r\n\r\nFor support, please visit: https:\/\/www.facebook.com\/groups\/wpformsvip\r\n*\/\r\n\r\n.wpforms-conditional-hide {\r\n position: absolute !important;\r\n left: -9999px !important;\r\n height: 0 !important;\r\n overflow: hidden !important;\r\n}\r\n\r\n.wpforms-conditional-hide * {\r\n visibility: hidden !important;\r\n} ","note":"If you use a multi-column layout with conditional fields, any fields that are conditionally shown...","categories":["wpforms"],"code_type":"css","needs_auth":false,"tags":[],"max_version":""},{"library_id":32157,"title":"Custom Style Icons for Rating field","code":"div.wpforms-container-full form#wpforms-form-1000 .wpforms-field-rating svg {\r\n fill: transparent !important;\r\n stroke: #448ccb !important;\r\n stroke-width: 20px !important;\r\n opacity: 1 !important;\r\n}\r\ndiv.wpforms-container-full form#wpforms-form-1000 .wpforms-field-rating-item svg:hover {\r\n fill: #448ccb !important;\r\n}\r\ndiv.wpforms-container-full form#wpforms-form-1000 .wpforms-field-rating-item.selected svg {\r\n fill: #448ccb !important;\r\n transform: none !important;\r\n}\r\n \r\ndiv.wpforms-container-full form#wpforms-form-1000 .wpforms-field-rating-item.hover svg {\r\n transform: none !important;\r\n}","note":"This snippet will customize your rating icons in the Rating field","categories":["wpforms"],"code_type":"css","needs_auth":false,"tags":["wpforms"],"max_version":""},{"library_id":21212,"title":"Custom Template File Hook","code":"\/\/ Add Custom Template File\r\ninclude_once( get_stylesheet_directory() . '\/wpforms-custom-templates.php' );","note":"This is the hook you will need in order to add custom form templates to...","categories":["wpforms"],"code_type":"php","needs_auth":false,"tags":[],"max_version":""},{"library_id":40846,"title":"Customizing Checkbox and Radio Fields to Look Like Buttons (All Forms)","code":".wpforms-container input[type=radio], \r\n.wpforms-container input[type=checkbox] {\r\n \tposition: absolute;\r\n opacity: 0;\r\n width: 1px;\r\n height: 1px;\r\n margin: -1px;\r\n padding: 0;\r\n overflow: hidden;\r\n clip: rect(0, 0, 0, 0);\r\n border: 0;}\r\n \r\n.wpforms-container input[type=radio] + label, \r\n.wpforms-container input[type=checkbox] + label {\r\n padding: 5px 10px !important;\r\n background-color: #e7e7e7 !important;\r\n border-color: #ddd !important;\r\n transition: background-color 0.3s ease-in-out !important;\r\n border-radius: 3px !important;\r\n}\r\n \r\n.wpforms-container input[type=radio]:checked + label, \r\n.wpforms-container input[type=checkbox]:checked + label, \r\n.wpforms-container input[type=radio]:checked + label, \r\n.wpforms-container input[type=radio] + label:hover, .wpforms-container input[type=checkbox] + label:hover {\r\n background-image: none !important;\r\n background-color: #b95d52 !important;\r\n color: #ffffff !important;\r\n cursor: pointer !important;\r\n}\r\n \r\n.wpforms-container ul li {\r\n margin: 5px !important;\r\n}\r\n\r\n\r\n\/* Start of media query to remove hover styles *\/\r\n@media (hover: none) {\r\n.wpforms-container input[type=radio] + label:hover, \r\n\t.wpforms-container input[type=checkbox] + label:hover {\r\n\tbackground-color: #e7e7e7 !important;\r\n border-color: #ddd !important;\r\n\tcolor: inherit !important;\r\n}\r\n\t.wpforms-container input[type=radio]:checked + label, \r\n\t.wpforms-container input[type=checkbox]:checked + label, \r\n\t.wpforms-container input[type=radio]:checked + label {\r\n background-image: none !important;\r\n background-color: #b95d52 !important;\r\n color: #ffffff !important;\r\n cursor: pointer !important;\r\n}\r\n\r\n}\r\n","note":"This code snippet will customize Checkbox and Radio fields to look like buttons for all...","categories":["wpforms"],"code_type":"css","needs_auth":false,"tags":["wpforms"],"max_version":""},{"library_id":40845,"title":"Customizing Checkbox and Radio Fields to Look Like Buttons (Specific Forms)","code":".wpforms-container form#wpforms-form-1000 input[type=radio], \r\n.wpforms-container form#wpforms-form-1000 input[type=checkbox] {\r\n position: absolute;\r\n opacity: 0;\r\n width: 1px;\r\n height: 1px;\r\n margin: -1px;\r\n padding: 0;\r\n overflow: hidden;\r\n clip: rect(0, 0, 0, 0);\r\n border: 0;\r\n}\r\n\r\n.wpforms-container form#wpforms-form-1000 input[type=radio] + label, \r\n.wpforms-container form#wpforms-form-1000 input[type=checkbox] + label {\r\n padding: 5px 10px;\r\n background-color: #e7e7e7;\r\n border-color: #ddd;\r\n transition: background-color 0.3s ease-in-out;\r\n\tborder-radius: 3px;\r\n}\r\n\r\nform#wpforms-form-1000 input[type=radio]:checked + label, \r\nform#wpforms-form-1000 input[type=checkbox]:checked + label, \r\nform#wpforms-form-1000 input[type=radio]:checked + label, \r\n.wpforms-container form#wpforms-form-1000 input[type=radio] + label:hover, \r\n.wpforms-container form#wpforms-form-1000 input[type=checkbox] + label:hover {\r\n background-image: none;\r\n background-color: #b95d52;\r\n\tcolor: #ffffff;\r\n cursor: pointer;\r\n}\r\n\r\n.wpforms-container form#wpforms-form-1000 ul li {\r\n margin: 5px !important;\r\n}\r\n\r\n\/* Start of media query to remove hover styles *\/\r\n@media (hover: none) {\r\n\t.wpforms-container form#wpforms-form-1000 input[type=radio] + label:hover, \r\n\t.wpforms-container form#wpforms-form-1000 input[type=checkbox] + label:hover {\r\n\t\tbackground-color: #e7e7e7 !important;\r\n\t\tborder-color: #ddd !important;\r\n\t\tcolor: inherit !important;\r\n\t}\r\n\r\n\t.wpforms-container form#wpforms-form-1000 input[type=radio]:checked + label, \r\n\t.wpforms-container form#wpforms-form-1000 input[type=checkbox]:checked + label, \r\n\t.wpforms-container form#wpforms-form-1000 input[type=radio]:checked + label {\r\n\t\tbackground-image: none !important;\r\n\t\tbackground-color: #b95d52 !important;\r\n\t\tcolor: #ffffff !important;\r\n\t\tcursor: pointer !important;\r\n\t}\r\n\r\n}","note":"This code snippet will customize Checkbox and Radio fields to look like buttons.","categories":["wpforms"],"code_type":"css","needs_auth":false,"tags":["wpforms"],"max_version":""},{"library_id":23029,"title":"Decrease the retention period to one week for the Action Scheduler","code":"\/* \r\nDecrease the retention period to one week for the Action Scheduler\r\n\r\nOriginal doc link: https:\/\/wpforms.com\/docs\/how-to-troubleshoot-action-scheduler-issues-in-wpforms\/\r\n\r\nFor support, please visit: https:\/\/www.facebook.com\/groups\/wpformsvip\r\n*\/\r\n\r\nfunction custom_as_retention_period() {\r\n return WEEK_IN_SECONDS;\r\n}\r\nadd_filter( 'action_scheduler_retention_period', 'custom_as_retention_period' );","note":"By default, Action Scheduler will automatically remove completed tasks after thirty days. However, this time...","categories":["wpforms"],"code_type":"php","needs_auth":false,"tags":[],"max_version":""},{"library_id":6191,"title":"Defer the reCAPTCHA Script","code":"\/**\r\n * Defer the reCAPTCHA script until after the page loads\r\n *\r\n * @link https:\/\/wpforms.com\/developers\/how-to-defer-the-recaptcha-script\/\r\n * \r\n * For support, please visit: https:\/\/www.facebook.com\/groups\/wpformsvip\r\n *\/\r\n\r\nfunction wpf_recaptcha_add_async_defer( $tag, $handle ) {\r\n \r\n if ( strpos( $tag, 'recaptcha\/api.js?onload=wpformsRecaptchaLoad' ) !== false ) {\r\n $tag = str_replace( ' src', ' defer async=\"async\" src', $tag );\r\n }\r\n \r\n return $tag;\r\n \r\n }\r\n \r\nadd_filter( 'script_loader_tag', 'wpf_recaptcha_add_async_defer', 10, 2 );\r\n","note":"Defers the reCAPTCHA script until after the page finishes loading.","categories":["wpforms"],"code_type":"php","needs_auth":false,"tags":["recaptcha"],"max_version":""},{"library_id":13524,"title":"Disable a Form Field to Prevent User Input","code":"\/**\r\n * Make standard form fields to make read-only\r\n * To apply, add CSS class 'wpf-disable-field' (no quotes) to field in form builder\r\n *\r\n * @link https:\/\/wpforms.com\/developers\/disable-a-form-field-to-prevent-user-input\/\r\n * \r\n * For support, please visit: https:\/\/www.facebook.com\/groups\/wpformsvip\r\n *\/\r\n \r\nfunction wpf_dev_disable_field() {\r\n ?>\r\n <script type=\"text\/javascript\">\r\n \r\n jQuery(function($) {\r\n \r\n $( '.wpf-disable-field input, .wpf-disable-field textarea' ).attr({\r\n readonly: \"readonly\",\r\n tabindex: \"-1\"\r\n });\r\n \r\n });\r\n \r\n <\/script>\r\n <?php\r\n}\r\nadd_action( 'wpforms_wp_footer_end', 'wpf_dev_disable_field', 30 );","note":"This snippet will render any Single Line Text or Paragraph Text field as read-only which...","categories":["wpforms"],"code_type":"php","needs_auth":false,"tags":[],"max_version":""},{"library_id":6149,"title":"Disable Enter Key in WPForms","code":"\/**\r\n * Disable the Enter key for WPForms forms\r\n *\r\n * @link https:\/\/wpforms.com\/developers\/how-to-stop-the-enter-key-from-submitting-the-form\/\r\n * \r\n * For support, please visit: https:\/\/www.facebook.com\/groups\/wpformsvip\r\n *\/\r\n \r\nfunction wpf_dev_disable_enter_all_wpforms( ) {\r\n?>\r\n \r\n <script type=\"text\/javascript\">\r\n \r\n \/\/ Run this snippet on all WPForms forms\r\n jQuery( 'form.wpforms-form' ).bind( 'keypress keydown keyup', function(e) {\r\n if (e.keyCode == 13) {\r\n e.preventDefault();\r\n }\r\n });\r\n \r\n <\/script>\r\n \r\n<?php\r\n}\r\nadd_action( 'wpforms_wp_footer_end', 'wpf_dev_disable_enter_all_wpforms', 30 );","note":"Disables the Enter key for all forms created with WPForms.","categories":["wpforms"],"code_type":"php","needs_auth":false,"tags":[],"max_version":""},{"library_id":6175,"title":"Disable the Email Address Suggestion","code":"\/**\r\n * Disable the email address suggestion\r\n *\r\n * @link https:\/\/wpforms.com\/developers\/how-to-disable-the-email-suggestion-on-the-email-form-field\/\r\n * \r\n * For support, please visit: https:\/\/www.facebook.com\/groups\/wpformsvip\r\n *\/\r\n \r\nadd_filter( 'wpforms_mailcheck_enabled', '__return_false' );","note":"Disables email address suggestion in the Email field.","categories":["wpforms"],"code_type":"php","needs_auth":false,"tags":[],"max_version":""},{"library_id":32160,"title":"Disable the space key with the special CSS class","code":"\/**\r\n * Disable the space key with the special CSS class\r\n * Apply the class \"wpf-disable-space\" to the field to enable.\r\n *\r\n * @link https:\/\/wpforms.com\/developers\/how-to-disable-the-space-key-inside-a-form-field\/\r\n *\r\n *\/\r\n \r\nfunction wpf_dev_disalbe_space() {\r\n ?>\r\n <script type=\"text\/javascript\">\r\n jQuery(document).ready(function ($) {\r\n \r\n jQuery( '.wpf-disable-space input' ).keydown(function(e) {\r\n \r\n if (event.key === ' ') {\r\n return false;\r\n }\r\n \r\n });\r\n \r\n });\r\n <\/script>\r\n <?php\r\n}\r\nadd_action( 'wpforms_wp_footer_end', 'wpf_dev_disalbe_space', 10 );","note":"This code snippet disables the space key. When a user presses the space key in...","categories":["wpforms"],"code_type":"php","needs_auth":false,"tags":["wpforms"],"max_version":""},{"library_id":32341,"title":"Disabling Past Times on the Date \/ Time Field","code":"\/**\r\n * Disable past times from the time field\r\n *\r\n * @link https:\/\/wpforms.com\/how-to-disable-past-times-on-the-time-picker\/\r\n *\/\r\n \r\nfunction wpf_dev_cond_time() {\r\n ?>\r\n <script type=\"text\/javascript\">\r\n \r\n \/\/ Find out the current time\r\n var now = new Date();\r\n \r\n \/\/ Take that current time and round it up so we have an even number on the interval\r\n now.setHours( now.getHours() + Math.round(now.getMinutes()\/90) );\r\n \r\n window.wpforms_999_8 = window.wpforms_999_8 || {};\r\n window.wpforms_999_8.timepicker = {\r\n forceRoundTime: true,\r\n \r\n \/\/ Disable any times that have passed already and return the new time selections\r\n minTime: now.toLocaleTimeString()\r\n };\r\n \r\n \r\n <\/script>\r\n <?php\r\n}\r\nadd_action( 'wpforms_wp_footer_end', 'wpf_dev_cond_time', 10 );","note":"This snippet disables past times on the Time Picker field in WPForms.","categories":["wpforms"],"code_type":"php","needs_auth":false,"tags":[],"max_version":""},{"library_id":6176,"title":"Display Empty Form Fields in Email Notifications","code":"\/**\r\n * Show empty form fields in email notifications\r\n *\r\n * @link https:\/\/wpforms.com\/developers\/how-to-show-empty-form-fields-in-email-notifications\/\r\n * \r\n * For support, please visit: https:\/\/www.facebook.com\/groups\/wpformsvip\r\n *\/\r\n \r\nadd_filter( 'wpforms_email_display_empty_fields', '__return_true' );\r\n","note":"Displays all fields in the email notifications including empty fields.","categories":["wpforms"],"code_type":"php","needs_auth":false,"tags":["notifications"],"max_version":""},{"library_id":13447,"title":"Display Entry Submissions Count for a Specific Form","code":"\/**\r\n * Shortcode that displays the number of completed entries for a form.\r\n *\r\n * Usage: [wpforms_entry_total form_id=\"X\"] - X is the form ID.\r\n *\r\n * @link https:\/\/wpforms.com\/developers\/display-entry-submissions-count-for-a-specific-form\/\r\n *\/\r\n \r\nfunction wpf_dev_form_entry_total( $atts ) {\r\n \r\n $args = shortcode_atts( array(\r\n 'form_id' => ''\r\n ), $atts );\r\n \r\n if ( empty( $atts[ 'form_id' ] ) ) {\r\n return;\r\n }\r\n \r\n $total = wpforms()->entry->get_entries( array( 'form_id' => $atts[ 'form_id' ] ), true );\r\n \r\n return absint( $total );\r\n}\r\nadd_shortcode( 'wpforms_entry_total', 'wpf_dev_form_entry_total' );\r\n","note":"Displays how many entries a specific form has received using a shortcode. Once this snippet...","categories":["wpforms"],"code_type":"php","needs_auth":false,"tags":[],"max_version":""},{"library_id":6182,"title":"Display Form After Confirmation","code":"\/**\r\n * Display form after confirmation\r\n *\r\n * @link https:\/\/wpforms.com\/developers\/how-to-display-the-confirmation-and-the-form-again-after-submission\/\r\n * \r\n * For support, please visit: https:\/\/www.facebook.com\/groups\/wpformsvip\r\n *\/\r\n \r\nfunction wpf_dev_frontend_output_success( $form_data, $fields, $entry_id ) {\r\n \r\n \/\/ Only process this snippet on form ID 999999\r\n \/\/ To find your form or field ID, visit https:\/\/wpforms.com\/developers\/how-to-locate-form-id-and-field-id\/\r\n if ( absint( $form_data[ 'id' ] ) !== 999999 ) {\r\n return;\r\n }\r\n \/\/ Reset the fields to blank\r\n unset(\r\n $_GET[ 'wpforms_return' ],\r\n $_POST[ 'wpforms' ][ 'id' ]\r\n );\r\n \r\n \/\/ Uncomment this line out if you want to clear the form field values after submission\r\n unset( $_POST[ 'wpforms' ][ 'fields' ] );\r\n \r\n \/\/ Actually render the form.\r\n wpforms()->frontend->output( $form_data[ 'id' ] );\r\n \r\n}\r\n \r\nadd_action( 'wpforms_frontend_output_success', 'wpf_dev_frontend_output_success', 10, 3 );\r\n","note":"Displays the form again after submission and below the confirmation message. Change the 999999 to...","categories":["wpforms"],"code_type":"php","needs_auth":false,"tags":["after-submission"],"max_version":""},{"library_id":6193,"title":"Display Form Entries","code":"\/**\r\n * Custom shortcode to display WPForms form entries in table view\r\n *\r\n * Basic usage: [wpforms_entries_table id=\"FORMID\"]\r\n * \r\n * @link https:\/\/wpforms.com\/developers\/how-to-display-form-entries\/\r\n * \r\n * For support, please visit: https:\/\/www.facebook.com\/groups\/wpformsvip\r\n *\/\r\n\r\nfunction wpf_entries_table( $atts ) {\r\n \r\n \/\/ Pull ID shortcode attributes.\r\n $atts = shortcode_atts(\r\n [\r\n 'id' => '',\r\n 'user' => '',\r\n 'fields' => '',\r\n 'number' => '',\r\n 'type' => 'all', \/\/ all, unread, read, or starred.\r\n 'sort' => '',\r\n 'order' => 'asc',\r\n ],\r\n $atts\r\n );\r\n \r\n \/\/ Check for an ID attribute (required) and that WPForms is in fact\r\n \/\/ installed and activated.\r\n if ( empty( $atts[ 'id' ] ) || ! function_exists( 'wpforms' ) ) {\r\n return;\r\n }\r\n \r\n \/\/ Get the form, from the ID provided in the shortcode.\r\n $form = wpforms()->form->get( absint( $atts[ 'id' ] ) );\r\n \r\n \/\/ If the form doesn't exists, abort.\r\n if ( empty( $form ) ) {\r\n return;\r\n }\r\n \r\n \/\/ Pull and format the form data out of the form object.\r\n $form_data = ! empty( $form->post_content ) ? wpforms_decode( $form->post_content ) : '';\r\n \r\n \/\/ Check to see if we are showing all allowed fields, or only specific ones.\r\n $form_field_ids = isset( $atts[ 'fields' ] ) && $atts[ 'fields' ] !== '' ? explode( ',', str_replace( ' ', '', $atts[ 'fields' ] ) ) : [];\r\n \r\n \/\/ Setup the form fields.\r\n if ( empty( $form_field_ids ) ) {\r\n $form_fields = $form_data[ 'fields' ];\r\n } else {\r\n $form_fields = [];\r\n foreach ( $form_field_ids as $field_id ) {\r\n if ( isset( $form_data[ 'fields' ][ $field_id ] ) ) {\r\n $form_fields[ $field_id ] = $form_data[ 'fields' ][ $field_id ];\r\n }\r\n }\r\n }\r\n \r\n if ( empty( $form_fields ) ) {\r\n return;\r\n }\r\n \r\n \/\/ Here we define what the types of form fields we do NOT want to include,\r\n \/\/ instead they should be ignored entirely.\r\n $form_fields_disallow = apply_filters( 'wpforms_frontend_entries_table_disallow', [ 'divider', 'html', 'pagebreak', 'captcha' ] );\r\n \r\n \/\/ Loop through all form fields and remove any field types not allowed.\r\n foreach ( $form_fields as $field_id => $form_field ) {\r\n if ( in_array( $form_field[ 'type' ], $form_fields_disallow, true ) ) {\r\n unset( $form_fields[ $field_id ] );\r\n }\r\n }\r\n \r\n $entries_args = [\r\n 'form_id' => absint( $atts[ 'id' ] ),\r\n ];\r\n \r\n \/\/ Narrow entries by user if user_id shortcode attribute was used.\r\n if ( ! empty( $atts[ 'user' ] ) ) {\r\n if ( $atts[ 'user' ] === 'current' && is_user_logged_in() ) {\r\n $entries_args[ 'user_id' ] = get_current_user_id();\r\n } else {\r\n $entries_args[ 'user_id' ] = absint( $atts[ 'user' ] );\r\n }\r\n }\r\n \r\n \/\/ Number of entries to show. If empty, defaults to 30.\r\n if ( ! empty( $atts[ 'number' ] ) ) {\r\n $entries_args[ 'number' ] = absint( $atts[ 'number' ] );\r\n }\r\n \r\n \/\/ Filter the type of entries all, unread, read, or starred\r\n if ( $atts[ 'type' ] === 'unread' ) {\r\n $entries_args[ 'viewed' ] = '0';\r\n } elseif( $atts[ 'type' ] === 'read' ) {\r\n $entries_args[ 'viewed' ] = '1';\r\n } elseif ( $atts[ 'type' ] === 'starred' ) {\r\n $entries_args[ 'starred' ] = '1';\r\n }\r\n \r\n \/\/ Get all entries for the form, according to arguments defined.\r\n \/\/ There are many options available to query entries. To see more, check out\r\n \/\/ the get_entries() function inside class-entry.php (https:\/\/a.cl.ly\/bLuGnkGx).\r\n $entries = json_decode(json_encode(wpforms()->entry->get_entries( $entries_args )), true);\r\n \r\n if ( empty( $entries ) ) {\r\n return '<p>No entries found.<\/p>';\r\n }\r\n \r\n foreach($entries as $key => $entry) {\r\n $entries[$key][ 'fields' ] = json_decode($entry[ 'fields' ], true);\r\n $entries[$key][ 'meta' ] = json_decode($entry[ 'meta' ], true);\r\n }\r\n \r\n if ( !empty($atts[ 'sort' ]) && isset($entries[0][ 'fields' ][$atts[ 'sort' ]] ) ) {\r\n if ( strtolower($atts[ 'order' ]) == 'asc' ) {\r\n usort($entries, function ($entry1, $entry2) use ($atts) {\r\n return strcmp($entry1[ 'fields' ][$atts[ 'sort' ]][ 'value' ], $entry2[ 'fields' ][$atts[ 'sort' ]][ 'value' ]);\r\n }); \r\n } elseif ( strtolower($atts[ 'order' ]) == 'desc' ) {\r\n usort($entries, function ($entry1, $entry2) use ($atts) {\r\n return strcmp($entry2[ 'fields' ][$atts[ 'sort' ]][ 'value' ], $entry1[ 'fields' ][$atts[ 'sort' ]]['value']);\r\n });\r\n }\r\n }\r\n \r\n ob_start();\r\n \r\n echo '<table class=\"wpforms-frontend-entries\">';\r\n \r\n echo '<thead><tr>';\r\n \r\n \/\/ Loop through the form data so we can output form field names in\r\n \/\/ the table header.\r\n foreach ( $form_fields as $form_field ) {\r\n \r\n \/\/ Output the form field name\/label.\r\n echo '<th>';\r\n echo esc_html( sanitize_text_field( $form_field[ 'label' ] ) );\r\n echo '<\/th>';\r\n }\r\n \r\n echo '<\/tr><\/thead>';\r\n \r\n echo '<tbody>';\r\n \r\n \/\/ Now, loop through all the form entries.\r\n foreach ( $entries as $entry ) {\r\n \r\n echo '<tr>';\r\n \r\n $entry_fields = $entry[ 'fields' ];\r\n \r\n foreach ( $form_fields as $form_field ) {\r\n \r\n echo '<td>';\r\n \r\n foreach ( $entry_fields as $entry_field ) {\r\n if ( absint( $entry_field[ 'id' ] ) === absint( $form_field[ 'id' ] ) ) {\r\n echo apply_filters( 'wpforms_html_field_value', wp_strip_all_tags( $entry_field[ 'value' ] ), $entry_field, $form_data, 'entry-frontend-table' );\r\n break;\r\n }\r\n }\r\n \r\n echo '<\/td>';\r\n }\r\n \r\n echo '<\/tr>';\r\n }\r\n \r\n echo '<\/tbody>';\r\n \r\n echo '<\/table>';\r\n \r\n $output = ob_get_clean();\r\n \r\n return $output;\r\n}\r\nadd_shortcode( 'wpforms_entries_table', 'wpf_entries_table' );","note":"Displays form entries on the front end of your site. Once this snippet is added...","categories":["wpforms"],"code_type":"php","needs_auth":false,"tags":["display-entries"],"max_version":""},{"library_id":6177,"title":"Display Non-Input Fields in Notifications","code":"\/**\r\n * Filters non-input field types to include in {all_fields} output\r\n *\r\n * @link https:\/\/wpforms.com\/developers\/include-page-break-section-divider-and-html-fields-in-notifications\/\r\n * \r\n * For support, please visit: https:\/\/www.facebook.com\/groups\/wpformsvip\r\n *\/\r\n \r\nfunction wpf_dev_email_display_other_fields( $fields ) {\r\n \r\n return array( 'divider', 'pagebreak', 'html', 'content' );\r\n}\r\n \r\nadd_filter( 'wpforms_email_display_other_fields', 'wpf_dev_email_display_other_fields', 10, 1 );\r\n","note":"Displays all non-input fields in email notifications. Non-input fields are HTML fields, Page Breaks, Section...","categories":["wpforms"],"code_type":"php","needs_auth":false,"tags":["notifications"],"max_version":""},{"library_id":6189,"title":"Display Shortcodes Inside HTML Fields","code":"\/**\r\n * Run shortcodes on HTML field content\r\n *\r\n * @link https:\/\/wpforms.com\/developers\/how-to-display-shortcodes-inside-the-html-field\/\r\n * \r\n * For support, please visit: https:\/\/www.facebook.com\/groups\/wpformsvip\r\n *\/\r\n\r\nfunction wpf_dev_html_field_shortcodes( $field, $field_atts, $form_data ) {\r\n \r\n if ( ! empty( $field[ 'code' ] ) ) {\r\n $field[ 'code' ] = do_shortcode( $field[ 'code' ] );\r\n }\r\n \r\n return $field;\r\n}\r\nadd_filter( 'wpforms_html_field_display', 'wpf_dev_html_field_shortcodes', 10, 3 );\r\n","note":"Allows shortcodes to be processed within HTML fields by applying do_shortcode() to the field content.","categories":["wpforms"],"code_type":"php","needs_auth":false,"tags":["html-field"],"max_version":""},{"library_id":33509,"title":"Displaying Shortcodes Inside Form Label Fields","code":"\/**\r\n * Run shortcodes on the form label field.\r\n *\r\n * @link https:\/\/wpforms.com\/developers\/how-to-display-shortcodes-inside-the-label-of-the-form-field\/\r\n *\/\r\n \r\nfunction add_shortcode_to_label( $field, $form_data ) {\r\n \r\n \/\/ Check that the form ID is 1055 and the field id is 4\r\n if ( 1055 === absint( $form_data[ 'id' ] ) && 4 === absint( $field[ 'id' ] ) ) {\r\n \r\n echo do_shortcode( ' [su_tooltip text=\"Your information is completely protected and will not be sold!<br><a href=https:\/\/myexamplesite.com\/privacy\/>Click here to learn more.<\/a>\" behavior=\"click\" hide_delay=\"500\"]Click Me![\/su_tooltip] ' );\r\n \r\n }\r\n}\r\nadd_action( 'wpforms_display_field_before', 'add_shortcode_to_label', 16, 2 );","note":"","categories":["wpforms"],"code_type":"php","needs_auth":false,"tags":[],"max_version":""},{"library_id":31497,"title":"Displaying the Total Number of Entries on Your Site","code":"\/**\r\n * Custom shortcode to display the total number of entries for a form.\r\n *\r\n * Basic usage: [wpf_entries_count id=\"FORMID\" type=\"TYPE\"]\r\n *\r\n * Realtime counts could be delayed due to any caching setup on the site\r\n *\r\n * @link https:\/\/wpforms.com\/developers\/how-to-display-the-total-number-of-entries\/\r\n *\/\r\n \r\nfunction wpf_entries_count( $atts ) {\r\n \r\n \/\/ Pull ID shortcode attributes such as the type of entries to count\r\n $atts = shortcode_atts(\r\n [\r\n 'id' => '',\r\n 'type' => 'all', \/\/ all, unread, read, or starred.\r\n ],\r\n $atts\r\n );\r\n \r\n if ( empty( $atts[ 'id' ] ) ) {\r\n return;\r\n }\r\n \r\n $args = [\r\n 'form_id' => absint( $atts[ 'id' ] ),\r\n ];\r\n \r\n \/\/ What types of entries do you want to show? The read, unread, starred or all?\r\n if ( $atts[ 'type' ] === 'unread' ) {\r\n $args[ 'viewed' ] = '0';\r\n } elseif( $atts[ 'type' ] === 'read' ) {\r\n $args[ 'viewed' ] = '1';\r\n } elseif ( $atts[ 'type' ] === 'starred' ) {\r\n $args[ 'starred' ] = '1';\r\n }\r\n \r\n return wpforms()->entry->get_entries( $args, true );\r\n \r\n}\r\nadd_shortcode( 'wpf_entries_count', 'wpf_entries_count' );","note":"This snippet creates a shortcode that you can use to display the total number of...","categories":["wpforms"],"code_type":"php","needs_auth":false,"tags":[],"max_version":""},{"library_id":35394,"title":"Dynamically Displaying Years in Your Forms","code":"\/**\r\n * Dynamically display years in the forms\r\n *\r\n * @link https:\/\/wpforms.com\/developers\/how-to-dynamically-display-years-in-your-forms\/\r\n *\/\r\n\r\nfunction wpf_dev_dynamic_school_year( ) {\r\n?>\r\n \r\n<script type=\"text\/javascript\">\r\n\t\r\n\twindow.onload = function() {\r\n \r\n\t\tdocument.getElementById( \"next-year\" ).innerHTML = new Date().getFullYear();\r\n document.getElementById( \"last-year\" ).innerHTML = new Date().getFullYear() - 1;\r\n\r\n\t};\r\n\r\n <\/script>\r\n \r\n<?php\r\n}\r\n \r\nadd_action( 'wpforms_wp_footer_end', 'wpf_dev_dynamic_school_year', 30 );","note":"","categories":["wpforms"],"code_type":"php","needs_auth":false,"tags":["wpforms"],"max_version":""},{"library_id":40840,"title":"Dynamically Setting Stripe Payment Description in WPForms","code":"\/**\r\n * Dynamically set Stripe payment description to include the current page\/post title.\r\n *\r\n * @link https:\/\/wpforms.com\/developers\/\r\n *\r\n * @param array $form_data Form data and settings.\r\n * @param array $entry Entry data.\r\n *\r\n * @return array\r\n *\/\r\nfunction wpf_dev_process_form_data( $form_data, $entry ) {\r\n \/\/ Get the current page\/post title\r\n $page_title = get_the_title();\r\n\r\n \/\/ Get the existing payment description and append the page title\r\n $form_data['payments']['stripe']['payment_description'] = $form_data['payments']['stripe']['payment_description'] . ' - ' . $page_title;\r\n\r\n return $form_data;\r\n}\r\nadd_filter( 'wpforms_process_before_form_data', 'wpf_dev_process_form_data', 10, 2 );\r\n","note":"To dynamically set the Stripe payment description, add the following code snippet to your site.","categories":["wpforms"],"code_type":"php","needs_auth":false,"tags":["wpforms"],"max_version":""},{"library_id":14932,"title":"Enable Legacy Email Templates","code":"\/**\r\n * Revert to legacy 'HTML' email template, v1.8.4 and below\r\n * \r\n * @link https:\/\/wpforms.com\/developers\/how-to-enable-legacy-email-template\/\r\n * \r\n * For support, please visit: https:\/\/www.facebook.com\/groups\/wpformsvip\r\n *\/\r\n\r\n$settings = (array) get_option( 'wpforms_settings', [] );\r\n$settings[ 'email-template' ] = 'default';\r\nupdate_option( 'wpforms_settings', $settings );","note":"This snippet will allow the ability to select Legacy from the WPForms >> Settings >>...","categories":["wpforms"],"code_type":"php","needs_auth":false,"tags":[],"max_version":""},{"library_id":32151,"title":"Focused Form Fields","code":"form#wpforms-form-1000 input:focus, form#wpforms-form-1000 textarea:focus {\r\n box-shadow: 5px 5px 10px #ccc;\r\n}\r\nform#wpforms-form-1000 input, form#wpforms-form-1000 textarea {\r\n transition: box-shadow 0.3s ease-in-out;\r\n}\r\n \r\nform#wpforms-form-1000 button[type=submit]:hover {\r\n box-shadow: 5px 5px 10px #ccc;\r\n border: 1px solid #ccc;\r\n background-color: #eee;\r\n}\r\n \r\nform#wpforms-form-1000 button[type=submit] {\r\n border: 1px solid transparent;\r\n transition: all 0.3s ease-in-out;\r\n}","note":"This CSS snippet will make your fields focused on click.","categories":["wpforms"],"code_type":"css","needs_auth":false,"tags":["wpforms"],"max_version":""},{"library_id":23032,"title":"Force WPForms to use modern markup","code":"\/* \r\nAdding a background image to your forms.\r\n\r\nOriginal doc link: https:\/\/wpforms.com\/docs\/styling-your-forms\/\r\n\r\nFor support, please visit: https:\/\/www.facebook.com\/groups\/wpformsvip\r\n*\/\r\n\r\nadd_filter( 'wpforms_admin_settings_modern_markup_register_field_is_disabled', '__return_false' );","note":"If using the deprecated Credit Card field prevents you from enabling modern markup, you can...","categories":["wpforms"],"code_type":"php","needs_auth":false,"tags":[],"max_version":""},{"library_id":33631,"title":"Generate and Send Invoice Number to Authorize.Net","code":"\/*\r\n * Include an invoice number into the set of Authorize.Net args.\r\n *\r\n * @link https:\/\/wpforms.com\/developers\/how-to-send-an-invoice-number-through-to-authorize-net-payments\r\n *\/\r\n \r\nfunction wpf_dev_authorize_net_process_payment_single_add_invoice_to_args( $args, $process ) {\r\n \r\n \/\/ Replace 20 in $process->fields[20] to an id of your invoice field.\r\n if ( isset( $process->fields[20][ 'value' ] ) ) {\r\n \r\n $args[ 'invoice' ] = $process->fields[20][ 'value' ];\r\n \r\n }\r\n \r\n return $args;\r\n}\r\n \r\nadd_filter( 'wpforms_authorize_net_process_payment_single_args', 'wpf_dev_authorize_net_process_payment_single_add_invoice_to_args', 10, 2 );\r\n \r\n\/**\r\n * Set the transaction order invoice number.\r\n *\r\n * @link https:\/\/wpforms.com\/developers\/how-to-send-an-invoice-number-through-to-authorize-net-payments\r\n *\/\r\n \r\nfunction wpf_dev_authorize_net_process_transaction_add_invoice_to_transaction( $transaction, $args ) {\r\n if ( ! isset( $args[ 'invoice' ] ) ) {\r\n return $transaction;\r\n }\r\n \r\n $order = $transaction->getOrder();\r\n if ( is_null( $order ) ) {\r\n $order = new \\net\\authorize\\api\\contract\\v1\\OrderType();\r\n }\r\n \r\n $order->setInvoiceNumber( $args[ 'invoice' ] );\r\n \r\n $transaction->setOrder( $order );\r\n \r\n return $transaction;\r\n}\r\n \r\nadd_filter( 'wpforms_authorize_net_process_transaction', 'wpf_dev_authorize_net_process_transaction_add_invoice_to_transaction', 10, 2 );","note":"This snippet generates and sends a unique invoice number to Authorize.Net for completed payments in...","categories":["wpforms"],"code_type":"php","needs_auth":false,"tags":[],"max_version":""},{"library_id":17686,"title":"Hide the Submit Button on Calculator Forms","code":"\/**\r\n * For the Accordion Template, this is a helper script\r\n * \r\n * For support, please visit: https:\/\/www.facebook.com\/groups\/wpformsvip\r\n *\/\r\n\r\n \/* CSS hide submit button for any calculator only forms *\/\r\nbutton.wpf-calc-form {\r\n\t\tvisibility: hidden;\r\n }","note":"To use any of the Calculator forms but want to hide the submit button. Use...","categories":["wpforms"],"code_type":"css","needs_auth":false,"tags":[],"max_version":""},{"library_id":30474,"title":"Hiding Page Breaks When Using Conditional Logic","code":"\/**\r\n * Skip empty page breaks if the condition is not met\r\n *\r\n * @link https:\/\/wpforms.com\/developers\/how-to-skip-page-breaks-when-using-conditional-logic\/\r\n *\/\r\n\r\nfunction wpf_dev_skip_empty_pages() {\r\n ?>\r\n <script type=\"text\/javascript\">\r\n jQuery(function($) {\r\n var action = \"\";\r\n\r\n $(document).on('click', '.wpforms-page-button', function() {\r\n action = $(this).data('action');\r\n });\r\n\r\n $('.wpforms-form').each(function() {\r\n $(this).on('wpformsBeforePageChange', function(event, pageNum, form) {\r\n setTimeout(function() {\r\n var emptyPage = true;\r\n \r\n form.find(`.wpforms-page-${pageNum} > div:not(:last)`).each(function() {\r\n var field = $(this);\r\n\r\n if (field.is(':visible')) {\r\n var hasInput = field.find('input, select, textarea').filter(function() {\r\n return $(this).val().trim() !== '';\r\n }).length > 0;\r\n\r\n if (hasInput) {\r\n emptyPage = false;\r\n window.wpforms_pageScroll = true;\r\n return false;\r\n }\r\n }\r\n });\r\n\r\n if (emptyPage) {\r\n window.wpforms_pageScroll = false;\r\n form.find(`.wpforms-page-${pageNum} .wpforms-page-${action}`).click();\r\n }\r\n }, 0);\r\n });\r\n });\r\n });\r\n <\/script>\r\n <?php\r\n}\r\n\r\nadd_action('wpforms_wp_footer_end', 'wpf_dev_skip_empty_pages', 30);","note":"This snippet will hide pages in your form that include fields hidden with conditional logic...","categories":["wpforms"],"code_type":"php","needs_auth":false,"tags":[],"max_version":""},{"library_id":40962,"title":"Hiding the Currency Symbol in WPForms Total Field","code":"function wpf_remove_currency_symbol() {\r\n ?>\r\n <script type=\"text\/javascript\">\r\n (function($){\r\n $(document).ready(function(){\r\n const targetNode = document.querySelector('.wpforms-payment-total');\r\n if (!targetNode) return;\r\n\r\n const config = { childList: true, subtree: true, characterData: true };\r\n \r\n const callback = function(mutationsList, observer) {\r\n for(let mutation of mutationsList) {\r\n if (mutation.type === 'childList' || mutation.type === 'characterData') {\r\n targetNode.textContent = targetNode.textContent.replace(\/[\u00a3$\u20ac]\/g, '');\r\n }\r\n }\r\n };\r\n\r\n const observer = new MutationObserver(callback);\r\n observer.observe(targetNode, config);\r\n\r\n \/\/ Initial removal of currency symbol\r\n targetNode.textContent = targetNode.textContent.replace(\/[\u00a3$\u20ac]\/g, '');\r\n });\r\n })(jQuery);\r\n <\/script>\r\n <?php\r\n}\r\nadd_action('wpforms_wp_footer', 'wpf_remove_currency_symbol', 30);","note":"This code snippet removes the following currency symbols from the Total field: \u00a3, $, \u20ac.","categories":["wpforms"],"code_type":"php","needs_auth":false,"tags":["wpforms"],"max_version":""},{"library_id":32588,"title":"How to Add Address Field Validation For Authorize.net","code":"\/**\r\n * Add address validation for Authorize.net address fields\r\n *\r\n * @link https:\/\/wpforms.com\/developers\/how-to-add-address-field-validation-for-authorize-net\/\r\n *\/\r\n \r\nfunction wpf_dev_authorize_address_validation( $fields, $entry, $form_data ) {\r\n \r\n \/\/ Optional, you can limit to specific forms. Below, we restrict output to\r\n \/\/ form #1000.\r\n if ( absint( $form_data[ 'id' ] ) !== 1000 ) {\r\n return $fields;\r\n }\r\n \r\n \/\/ check the field ID 25 to see if it's empty and if it is, run the error \r\n if ( strlen( $fields[25][ 'value' ] ) > 60 )\r\n {\r\n \/\/ Check the field ID 25 and show error message at the top of form and under the specific field\r\n wpforms()->process->errors[ $form_data[ 'id' ] ] [ '25' ] = esc_html__( 'The characters for the address line must not exceed 60.', 'plugin-domain' );\r\n }\r\n }\r\nadd_action( 'wpforms_process', 'wpf_dev_authorize_address_validation', 10, 3 );","note":"","categories":["wpforms"],"code_type":"php","needs_auth":false,"tags":["wpforms"],"max_version":""},{"library_id":31680,"title":"How to Add an Empty Dropdown to Dropdown Items","code":"\/**\r\n* Empty dropdown item without the price showing for payment dropdown selection.\r\n*\r\n* @link https:\/\/wpforms.com\/developers\/how-to-add-an-empty-dropdown-to-dropdown-items\/\r\n*\/\r\nfunction wpf_dev_empty_dropdown_item() {\r\n ?>\r\n <script type=\"text\/javascript\">\r\n jQuery('.wpforms-payment-price option[data-amount=\"0.00\"]').text('--Select--');\r\n <\/script>\r\n <?php\r\n}\r\nadd_action('wpforms_wp_footer_end', 'wpf_dev_empty_dropdown_item', 30);","note":"This snippet maintains a clean \"--Select--\" option without the zero price display when using the...","categories":["wpforms"],"code_type":"php","needs_auth":false,"tags":["wpforms"],"max_version":""},{"library_id":33064,"title":"How to Add an Input Mask to the International Postal Code","code":"\/*\r\n * Custom input mask for the address field's international scheme.\r\n * \r\n * @link https:\/\/wpforms.com\/developers\/how-to-add-an-input-mask-to-the-international-postal-code\r\n*\/\r\n \r\nfunction wpf_dev_address_field_properties( $properties, $field, $form_data ) {\r\n \r\n if($field[ 'scheme' ] === 'international') {\r\n \r\n $properties[ 'inputs' ][ 'postal' ][ 'class' ][] = 'wpforms-masked-input';\r\n $properties[ 'inputs' ][ 'postal' ][ 'data' ][ 'inputmask-mask' ] = '999999';\r\n $properties[ 'inputs' ][ 'postal' ][ 'data' ][ 'inputmask-greedy' ] = 'false';\r\n $properties[ 'inputs' ][ 'postal' ][ 'data' ][ 'rule-empty-blanks' ] = true;\r\n \r\n }\r\n \r\n return $properties; \r\n \r\n}\r\n add_action( 'wpforms_field_properties_address', 'wpf_dev_address_field_properties', 10, 3 )","note":"","categories":["wpforms"],"code_type":"php","needs_auth":false,"tags":[],"max_version":""},{"library_id":33055,"title":"How to Add BCC to Email Notifications (for all forms)","code":"add_filter( 'wp_mail', function ( $args ) {\r\n \/\/ Add the BCC email address here\r\n $bcc_address = 'Bcc: pattie@example.com';\r\n \r\n if ( ! empty( $args[ 'headers' ] ) ) {\r\n if ( ! is_array( $args[ 'headers' ] ) ) {\r\n $args[ 'headers' ] = array_filter( explode( \"\\n\", str_replace( \"\\r\\n\", \"\\n\", $args[ 'headers' ] ) ) );\r\n }\r\n } else {\r\n $args[ 'headers' ] = [];\r\n }\r\n $args[ 'headers' ][] = $bcc_address;\r\n return $args;\r\n});","note":"","categories":["wpforms"],"code_type":"php","needs_auth":false,"tags":[],"max_version":""},{"library_id":33054,"title":"How to Add BCC to Email Notifications (for specific form)","code":"\/**\r\n * Add BCC recipients to specific form email notifications.\r\n *\r\n * @link https:\/\/wpforms.com\/docs\/how-to-add-bcc-to-email-notifications\/\r\n *\/\r\n \r\nadd_filter( 'wp_mail', function ( $args ) {\r\n\/\/ Use WPForms_Process object to get the form ID\r\n$wpforms_process = wpforms()->process;\r\n\r\n\/\/ Only run this snippet on form ID 1000\r\nif ( $wpforms_process->form_data['id'] == 1000 ) {\r\n\r\n \/\/ Add the BCC email address here\r\n $bcc_address = 'Bcc: pattie@example.com';\r\n\r\n if ( ! empty( $args[ 'headers' ] ) ) {\r\n\r\n if ( ! is_array( $args[ 'headers' ] ) ) {\r\n\r\n $args[ 'headers' ] = array_filter( explode( \"\\n\", str_replace( \"\\r\\n\", \"\\n\", $args[ 'headers' ] ) ) );\r\n }\r\n\r\n } else {\r\n\r\n $args[ 'headers' ] = [];\r\n\r\n }\r\n\r\n $args[ 'headers' ][] = $bcc_address;\r\n\r\n \r\n}\r\n\r\nreturn $args;\r\n\r\n});","note":"","categories":["wpforms"],"code_type":"php","needs_auth":false,"tags":[],"max_version":""},{"library_id":32591,"title":"How to Add Confetti Animation to Confirmation Message","code":"**\r\n * Add confetti to the canvas element on the confirmation message\r\n *\r\n * @link https:\/\/wpforms.com\/developers\/how-to-add-confetti-animation-to-confirmation-message\/\r\n *\/\r\n \r\nfunction wpf_confetti_animation() {\r\n ?>\r\n \r\n <script type=\"text\/javascript\">\r\n \r\n \/\/If the canvas ID does not exist on the page, this script will not run\r\n if (document.querySelector( '#animateCanvas' ) !== null) { \r\n \r\n class Progress {\r\n constructor(param = {}) {\r\n this.timestamp = null;\r\n this.duration = param.duration || Progress.CONST.DURATION;\r\n this.progress = 0;\r\n this.delta = 0;\r\n this.progress = 0;\r\n this.isLoop = !!param.isLoop;\r\n \r\n this.reset();\r\n }\r\n \r\n static get CONST() {\r\n return {\r\n DURATION : 1000\r\n };\r\n }\r\n \r\n reset() {\r\n this.timestamp = null;\r\n }\r\n \r\n start(now) {\r\n this.timestamp = now;\r\n }\r\n \r\n tick(now) {\r\n if (this.timestamp) {\r\n this.delta = now - this.timestamp;\r\n this.progress = Math.min(this.delta \/ this.duration, 1);\r\n \r\n if (this.progress >= 1 && this.isLoop) {\r\n this.start(now);\r\n }\r\n \r\n return this.progress;\r\n } else {\r\n return 0;\r\n }\r\n }\r\n }\r\n \r\n class Confetti {\r\n constructor(param) {\r\n this.parent = param.elm || document.body;\r\n this.canvas = document.createElement(\"canvas\");\r\n this.ctx = this.canvas.getContext(\"2d\");\r\n this.width = param.width || this.parent.offsetWidth;\r\n this.height = param.height || this.parent.offsetHeight;\r\n this.length = param.length || Confetti.CONST.PAPER_LENGTH;\r\n this.yRange = param.yRange || this.height * 2;\r\n this.progress = new Progress({\r\n duration : param.duration,\r\n isLoop : true\r\n });\r\n this.rotationRange = typeof param.rotationLength === \"number\" ? param.rotationRange\r\n : 10;\r\n this.speedRange = typeof param.speedRange === \"number\" ? param.speedRange\r\n : 10;\r\n this.sprites = [];\r\n \r\n this.canvas.style.cssText = [\r\n \"display: block\",\r\n \"position: absolute\",\r\n \"top: 0\",\r\n \"left: 0\",\r\n \"pointer-events: none\"\r\n ].join(\";\");\r\n \r\n this.render = this.render.bind(this);\r\n \r\n this.build();\r\n \r\n this.parent.appendChild(this.canvas);\r\n this.progress.start(performance.now());\r\n \r\n requestAnimationFrame(this.render);\r\n }\r\n \r\n static get CONST() {\r\n return {\r\n \/\/CUSTOMIZE: This will adjust how wide the paper is \r\n SPRITE_WIDTH : 9,\r\n \/\/CUSTOMIZE: This will adjust how tall the paper is\r\n SPRITE_HEIGHT : 16,\r\n \/\/CUSTOMIZE: This will adjust how much confetti appears, raise the number for less confetti\r\n PAPER_LENGTH : 100,\r\n \/\/CUSTOMIZE: This will control the rotation rate of each piece of confetti\r\n ROTATION_RATE : 50,\r\n \/\/CUSTOMIZE: These are the default colors used for the confetti. You can change these numbers or add to them. \r\n \/\/CUSTOMIZE: Separate adding new colors by a comma after each new color added.\r\n COLORS : [\r\n \"#EF5350\",\r\n \"#EC407A\",\r\n \"#AB47BC\",\r\n \"#7E57C2\",\r\n \"#5C6BC0\",\r\n \"#42A5F5\",\r\n \"#29B6F6\",\r\n \"#26C6DA\",\r\n \"#26A69A\",\r\n \"#66BB6A\",\r\n \"#9CCC65\",\r\n \"#D4E157\",\r\n \"#FFEE58\",\r\n \"#FFCA28\",\r\n \"#FFA726\",\r\n \"#FF7043\",\r\n \"#8D6E63\",\r\n \"#BDBDBD\",\r\n \"#78909C\" ]\r\n };\r\n }\r\n \r\n build() {\r\n for (let i = 0; i < this.length; ++i) {\r\n let canvas = document.createElement(\"canvas\"),\r\n ctx = canvas.getContext(\"2d\");\r\n \r\n canvas.width = Confetti.CONST.SPRITE_WIDTH;\r\n canvas.height = Confetti.CONST.SPRITE_HEIGHT;\r\n \r\n canvas.position = {\r\n initX : Math.random() * this.width,\r\n initY : -canvas.height - Math.random() * this.yRange\r\n };\r\n \r\n canvas.rotation = (this.rotationRange \/ 2) - Math.random() * this.rotationRange;\r\n canvas.speed = (this.speedRange \/ 2) + Math.random() * (this.speedRange \/ 2);\r\n \r\n ctx.save();\r\n ctx.fillStyle = Confetti.CONST.COLORS[(Math.random() * Confetti.CONST.COLORS.length) | 0];\r\n ctx.fillRect(0, 0, canvas.width, canvas.height);\r\n ctx.restore();\r\n \r\n this.sprites.push(canvas);\r\n }\r\n }\r\n \r\n render(now) {\r\n let progress = this.progress.tick(now);\r\n \r\n this.canvas.width = this.width;\r\n this.canvas.height = this.height;\r\n \r\n for (let i = 0; i < this.length; ++i) {\r\n this.ctx.save();\r\n this.ctx.translate(\r\n this.sprites[i].position.initX + this.sprites[i].rotation * Confetti.CONST.ROTATION_RATE * progress,\r\n this.sprites[i].position.initY + progress * (this.height + this.yRange)\r\n );\r\n this.ctx.rotate(this.sprites[i].rotation);\r\n this.ctx.drawImage(\r\n this.sprites[i],\r\n -Confetti.CONST.SPRITE_WIDTH * Math.abs(Math.sin(progress * Math.PI * 2 * this.sprites[i].speed)) \/ 2,\r\n -Confetti.CONST.SPRITE_HEIGHT \/ 2,\r\n Confetti.CONST.SPRITE_WIDTH * Math.abs(Math.sin(progress * Math.PI * 2 * this.sprites[i].speed)),\r\n Confetti.CONST.SPRITE_HEIGHT\r\n );\r\n this.ctx.restore();\r\n }\r\n \r\n requestAnimationFrame(this.render);\r\n }\r\n }\r\n \r\n (() => {\r\n \/\/CUSTOMIZE: This will control the speed of how fast the confetti falls, raise the number for a slower fall.\r\n const DURATION = 8000,\r\n \/\/CUSTOMIZE: This number controls how much confetti will appear on the screen. For more confetti, raise the number.\r\n LENGTH = 120;\r\n \r\n new Confetti({\r\n width : window.innerWidth,\r\n height : window.innerHeight,\r\n length : LENGTH,\r\n duration : DURATION\r\n });\r\n \r\n setTimeout(() => {\r\n new Confetti({\r\n width : window.innerWidth,\r\n height : window.innerHeight,\r\n length : LENGTH,\r\n duration : DURATION\r\n });\r\n }, DURATION \/ 2);\r\n })();\r\n \r\n }\r\n <\/script>\r\n <?php\r\n}\r\nadd_action( 'wpforms_wp_footer_end', 'wpf_confetti_animation', 1);","note":"","categories":["wpforms"],"code_type":"php","needs_auth":false,"tags":["wpforms"],"max_version":""},{"library_id":23026,"title":"How to Add Custom Code Snippets in WordPress","code":"\r\n\/* \r\nModify the login URL to redirect to a custom login page.\r\n\r\nOriginal doc link: https:\/\/wpforms.com\/how-to-add-custom-code-snippets-in-wordpress\/\r\n\r\nFor support, please visit: https:\/\/www.facebook.com\/groups\/wpformsvip\r\n*\/\r\n.wpforms-container input[type=radio] {\r\n -webkit-appearance: radio !important;\r\n -moz-appearance: radio !important;\r\n appearance: radio !important;\r\n}\r\n \r\n.wpforms-container input[type=checkbox] {\r\n -webkit-appearance: checkbox !important;\r\n -moz-appearance: checkbox !important;\r\n appearance: checkbox !important;\r\n}\r\n \r\n.wpforms-container input[type=radio]:checked:before,\r\n.wpforms-container input[type=radio]:before,\r\n.wpforms-container input[type=checkbox]:checked:before,\r\n.wpforms-container input[type=checkbox]:before,\r\n.wpforms-container input[type=radio]:checked:after,\r\n.wpforms-container input[type=radio]:after,\r\n.wpforms-container input[type=checkbox]:checked:after,\r\n.wpforms-container input[type=checkbox]:after {\r\n display: none !important;\r\n}","note":"For this guide, we\u2019ll create a custom code that prevents theme conflicts that cause Radio...","categories":["wpforms"],"code_type":"css","needs_auth":false,"tags":[],"max_version":""},{"library_id":32592,"title":"How to Add Firework Animation to Confirmation Message","code":"\/**\r\n * Add fireworks to the canvas element on the confirmation message\r\n *\r\n * @link https:\/\/wpforms.com\/developers\/how-to-add-confetti-animation-to-confirmation-message\/\r\n *\/\r\n \r\nfunction wpf_fireworks_animation() {\r\n ?>\r\n \r\n <script type=\"text\/javascript\">\r\n \r\n window.requestAnimFrame = ( function() {\r\n return window.requestAnimationFrame ||\r\n window.webkitRequestAnimationFrame ||\r\n window.mozRequestAnimationFrame ||\r\n function( callback ) {\r\n window.setTimeout( callback, 1000 \/ 60 );\r\n };\r\n })();\r\n \r\n \/\/ now we will setup our basic variables for the demo\r\n var canvas = document.getElementById( 'animateCanvas' ),\r\n ctx = canvas.getContext( '2d' ),\r\n \/\/ full screen dimensions\r\n cw = window.innerWidth,\r\n ch = window.innerHeight,\r\n \/\/ firework collection\r\n fireworks = [],\r\n \/\/ particle collection\r\n particles = [],\r\n \/\/ starting hue\r\n hue = 120,\r\n \/\/ when launching fireworks with a click, too many get launched at once without a limiter, one launch per 5 loop ticks\r\n limiterTotal = 2,\r\n limiterTick = 0,\r\n \/\/ this will time the auto launches of fireworks, one launch per 80 loop ticks\r\n timerTotal = 40,\r\n timerTick = 0,\r\n mousedown = false,\r\n \/\/ mouse x coordinate,\r\n mx,\r\n \/\/ mouse y coordinate\r\n my;\r\n \r\n \/\/ set canvas dimensions\r\n canvas.width = cw;\r\n canvas.height = ch;\r\n \r\n \/\/ now we are going to setup our function placeholders for the entire demo\r\n \r\n \/\/ get a random number within a range\r\n function random( min, max ) {\r\n return Math.random() * ( max - min ) + min;\r\n }\r\n \r\n \/\/ calculate the distance between two points\r\n function calculateDistance( p1x, p1y, p2x, p2y ) {\r\n var xDistance = p1x - p2x,\r\n yDistance = p1y - p2y;\r\n return Math.sqrt( Math.pow( xDistance, 2 ) + Math.pow( yDistance, 2 ) );\r\n }\r\n \r\n \/\/ create firework\r\n function Firework( sx, sy, tx, ty ) {\r\n \/\/ actual coordinates\r\n this.x = sx;\r\n this.y = sy;\r\n \/\/ starting coordinates\r\n this.sx = sx;\r\n this.sy = sy;\r\n \/\/ target coordinates\r\n this.tx = tx;\r\n this.ty = ty;\r\n \/\/ distance from starting point to target\r\n this.distanceToTarget = calculateDistance( sx, sy, tx, ty );\r\n this.distanceTraveled = 0;\r\n \/\/ track the past coordinates of each firework to create a trail effect, increase the coordinate count to create more prominent trails\r\n this.coordinates = [];\r\n this.coordinateCount = 3;\r\n \/\/ populate initial coordinate collection with the current coordinates\r\n while( this.coordinateCount-- ) {\r\n this.coordinates.push( [ this.x, this.y ] );\r\n }\r\n this.angle = Math.atan2( ty - sy, tx - sx );\r\n this.speed = 2;\r\n this.acceleration = 1.05;\r\n this.brightness = random( 50, 70 );\r\n \/\/ circle target indicator radius\r\n this.targetRadius = 1;\r\n }\r\n \r\n \/\/ update firework\r\n Firework.prototype.update = function( index ) {\r\n \/\/ remove last item in coordinates array\r\n this.coordinates.pop();\r\n \/\/ add current coordinates to the start of the array\r\n this.coordinates.unshift( [ this.x, this.y ] );\r\n \r\n \/\/ cycle the circle target indicator radius\r\n if( this.targetRadius < 8 ) {\r\n this.targetRadius += 0.3;\r\n } else {\r\n this.targetRadius = 1;\r\n }\r\n \r\n \/\/ speed up the firework\r\n this.speed *= this.acceleration;\r\n \r\n \/\/ get the current velocities based on angle and speed\r\n var vx = Math.cos( this.angle ) * this.speed,\r\n vy = Math.sin( this.angle ) * this.speed;\r\n \/\/ how far will the firework have traveled with velocities applied?\r\n this.distanceTraveled = calculateDistance( this.sx, this.sy, this.x + vx, this.y + vy );\r\n \r\n \/\/ if the distance traveled, including velocities, is greater than the initial distance to the target, then the target has been reached\r\n if( this.distanceTraveled >= this.distanceToTarget ) {\r\n createParticles( this.tx, this.ty );\r\n \/\/ remove the firework, use the index passed into the update function to determine which to remove\r\n fireworks.splice( index, 1 );\r\n } else {\r\n \/\/ target not reached, keep traveling\r\n this.x += vx;\r\n this.y += vy;\r\n }\r\n }\r\n \r\n \/\/ draw firework\r\n Firework.prototype.draw = function() {\r\n ctx.beginPath();\r\n \/\/ move to the last tracked coordinate in the set, then draw a line to the current x and y\r\n ctx.moveTo( this.coordinates[ this.coordinates.length - 1][ 0 ], this.coordinates[ this.coordinates.length - 1][ 1 ] );\r\n ctx.lineTo( this.x, this.y );\r\n ctx.strokeStyle = 'hsl(' + hue + ', 100%, ' + this.brightness + '%)';\r\n ctx.stroke();\r\n \r\n ctx.beginPath();\r\n \/\/ draw the target for this firework with a pulsing circle\r\n ctx.arc( this.tx, this.ty, this.targetRadius, 0, Math.PI * 2 );\r\n ctx.stroke();\r\n }\r\n \r\n \/\/ create particle\r\n function Particle( x, y ) {\r\n this.x = x;\r\n this.y = y;\r\n \/\/ track the past coordinates of each particle to create a trail effect, increase the coordinate count to create more prominent trails\r\n this.coordinates = [];\r\n this.coordinateCount = 5;\r\n while( this.coordinateCount-- ) {\r\n this.coordinates.push( [ this.x, this.y ] );\r\n }\r\n \/\/ set a random angle in all possible directions, in radians\r\n this.angle = random( 0, Math.PI * 2 );\r\n this.speed = random( 1, 10 );\r\n \/\/ friction will slow the particle down\r\n this.friction = 0.95;\r\n \/\/ gravity will be applied and pull the particle down\r\n this.gravity = 1;\r\n \/\/ set the hue to a random number +-20 of the overall hue variable\r\n this.hue = random( hue - 20, hue + 20 );\r\n this.brightness = random( 50, 80 );\r\n this.alpha = 1;\r\n \/\/ set how fast the particle fades out\r\n this.decay = random( 0.015, 0.03 );\r\n }\r\n \r\n \/\/ update particle\r\n Particle.prototype.update = function( index ) {\r\n \/\/ remove last item in coordinates array\r\n this.coordinates.pop();\r\n \/\/ add current coordinates to the start of the array\r\n this.coordinates.unshift( [ this.x, this.y ] );\r\n \/\/ slow down the particle\r\n this.speed *= this.friction;\r\n \/\/ apply velocity\r\n this.x += Math.cos( this.angle ) * this.speed;\r\n this.y += Math.sin( this.angle ) * this.speed + this.gravity;\r\n \/\/ fade out the particle\r\n this.alpha -= this.decay;\r\n \r\n \/\/ remove the particle once the alpha is low enough, based on the passed in index\r\n if( this.alpha <= this.decay ) {\r\n particles.splice( index, 1 );\r\n }\r\n }\r\n \r\n \/\/ draw particle\r\n Particle.prototype.draw = function() {\r\n ctx. beginPath();\r\n \/\/ move to the last tracked coordinates in the set, then draw a line to the current x and y\r\n ctx.moveTo( this.coordinates[ this.coordinates.length - 1 ][ 0 ], this.coordinates[ this.coordinates.length - 1 ][ 1 ] );\r\n ctx.lineTo( this.x, this.y );\r\n ctx.strokeStyle = 'hsla(' + this.hue + ', 100%, ' + this.brightness + '%, ' + this.alpha + ')';\r\n ctx.stroke();\r\n }\r\n \r\n \/\/ create particle group\/explosion\r\n function createParticles( x, y ) {\r\n \/\/ increase the particle count for a bigger explosion, beware of the canvas performance hit with the increased particles though\r\n var particleCount = 80;\r\n while( particleCount-- ) {\r\n particles.push( new Particle( x, y ) );\r\n }\r\n }\r\n \r\n \/\/ main demo loop\r\n function loop() {\r\n \/\/ this function will run endlessly with requestAnimationFrame\r\n requestAnimFrame( loop );\r\n \r\n \/\/ increase the hue to get different colored fireworks over time\r\n hue += 0.5;\r\n \r\n \/\/ normally, clearRect() would be used to clear the canvas\r\n \/\/ we want to create a trailing effect though\r\n \/\/ setting the composite operation to destination-out will allow us to clear the canvas at a specific opacity, rather than wiping it entirely\r\n ctx.globalCompositeOperation = 'destination-out';\r\n \/\/ decrease the alpha property to create more prominent trails\r\n ctx.fillStyle = 'rgba(0, 0, 0, 0.5)';\r\n ctx.fillRect( 0, 0, cw, ch );\r\n \/\/ change the composite operation back to our main mode\r\n \/\/ lighter creates bright highlight points as the fireworks and particles overlap each other\r\n ctx.globalCompositeOperation = 'lighter';\r\n \r\n \/\/ loop over each firework, draw it, update it\r\n var i = fireworks.length;\r\n while( i-- ) {\r\n fireworks[ i ].draw();\r\n fireworks[ i ].update( i );\r\n }\r\n \r\n \/\/ loop over each particle, draw it, update it\r\n var i = particles.length;\r\n while( i-- ) {\r\n particles[ i ].draw();\r\n particles[ i ].update( i );\r\n }\r\n \r\n \/\/ launch fireworks automatically to random coordinates, when the mouse isn't down\r\n if( timerTick >= timerTotal ) {\r\n if( !mousedown ) {\r\n \/\/ start the firework at the bottom middle of the screen, then set the random target coordinates, the random y coordinates will be set within the range of the top half of the screen\r\n fireworks.push( new Firework( cw \/ 2, ch, random( 0, cw ), random( 0, ch \/ 2 ) ) );\r\n timerTick = 0;\r\n }\r\n } else {\r\n timerTick++;\r\n }\r\n \r\n \/\/ limit the rate at which fireworks get launched when mouse is down\r\n if( limiterTick >= limiterTotal ) {\r\n if( mousedown ) {\r\n \/\/ start the firework at the bottom middle of the screen, then set the current mouse coordinates as the target\r\n fireworks.push( new Firework( cw \/ 2, ch, mx, my ) );\r\n limiterTick = 0;\r\n }\r\n } else {\r\n limiterTick++;\r\n }\r\n }\r\n \r\n \/\/ mouse event bindings\r\n \/\/ update the mouse coordinates on mousemove\r\n canvas.addEventListener( 'mousemove', function( e ) {\r\n mx = e.pageX - canvas.offsetLeft;\r\n my = e.pageY - canvas.offsetTop;\r\n });\r\n \r\n \/\/ toggle mousedown state and prevent canvas from being selected\r\n canvas.addEventListener( 'mousedown', function( e ) {\r\n e.preventDefault();\r\n mousedown = true;\r\n });\r\n \r\n canvas.addEventListener( 'mouseup', function( e ) {\r\n e.preventDefault();\r\n mousedown = false;\r\n });\r\n \r\n \/\/ once the window loads, we are ready for some fireworks!\r\n window.onload = loop;\r\n \r\n \r\n <\/script>\r\n <?php\r\n}\r\nadd_action( 'wpforms_wp_footer_end', 'wpf_fireworks_animation', 1);","note":"","categories":["wpforms"],"code_type":"php","needs_auth":false,"tags":["wpforms"],"max_version":""},{"library_id":33042,"title":"How to Add JavaScript to a Page When Using the Form Pages Addon","code":"\/**\r\n * Add confetti to the convas element on the confirmation message for Form Pages\r\n *\r\n * @link https:\/\/wpforms.com\/developers\/how-to-add-javascript-to-a-page-when-using-the-form-pages-addon\/\r\n *\/\r\n \r\nfunction wpf_confetti_animation() {\r\n ?>\r\n <script type=\"text\/javascript\">\r\n \r\n\/\/If the canvas ID does not exist on the page, this script will not run\r\n \r\nif (document.querySelector( '#canvas' ) !== null) { \r\n \r\nclass Progress {\r\n constructor(param = {}) {\r\n this.timestamp = null;\r\n this.duration = param.duration || Progress.CONST.DURATION;\r\n this.progress = 0;\r\n this.delta = 0;\r\n this.progress = 0;\r\n this.isLoop = !!param.isLoop;\r\n \r\n this.reset();\r\n }\r\n \r\n static get CONST() {\r\n return {\r\n DURATION : 1000\r\n };\r\n }\r\n \r\n reset() {\r\n this.timestamp = null;\r\n }\r\n \r\n start(now) {\r\n this.timestamp = now;\r\n }\r\n \r\n tick(now) {\r\n if (this.timestamp) {\r\n this.delta = now - this.timestamp;\r\n this.progress = Math.min(this.delta \/ this.duration, 1);\r\n \r\n if (this.progress >= 1 && this.isLoop) {\r\n this.start(now);\r\n }\r\n \r\n return this.progress;\r\n } else {\r\n return 0;\r\n }\r\n }\r\n}\r\n \r\nclass Confetti {\r\n constructor(param) {\r\n this.parent = param.elm || document.body;\r\n this.canvas = document.createElement(\"canvas\");\r\n this.ctx = this.canvas.getContext(\"2d\");\r\n this.width = param.width || this.parent.offsetWidth;\r\n this.height = param.height || this.parent.offsetHeight;\r\n this.length = param.length || Confetti.CONST.PAPER_LENGTH;\r\n this.yRange = param.yRange || this.height * 2;\r\n this.progress = new Progress({\r\n duration : param.duration,\r\n isLoop : true\r\n });\r\n this.rotationRange = typeof param.rotationLength === \"number\" ? param.rotationRange\r\n : 10;\r\n this.speedRange = typeof param.speedRange === \"number\" ? param.speedRange\r\n : 10;\r\n this.sprites = [];\r\n \r\n this.canvas.style.cssText = [\r\n \"display: block\",\r\n \"position: absolute\",\r\n \"top: 0\",\r\n \"left: 0\",\r\n \"pointer-events: none\"\r\n ].join(\";\");\r\n \r\n this.render = this.render.bind(this);\r\n \r\n this.build();\r\n \r\n this.parent.appendChild(this.canvas);\r\n this.progress.start(performance.now());\r\n \r\n requestAnimationFrame(this.render);\r\n }\r\n \r\n static get CONST() {\r\n return {\r\n \/\/CUSTOMIZE: This will adjust how wide the paper is \r\n SPRITE_WIDTH : 9,\r\n \/\/CUSTOMIZE: This will adjust how tall the paper is\r\n SPRITE_HEIGHT : 16,\r\n \/\/CUSTOMIZE: This will adjust how much confetti appears, raise the number for less confetti\r\n PAPER_LENGTH : 100,\r\n \/\/CUSTOMIZE: This will control the rotation rate of each piece of confetti\r\n ROTATION_RATE : 50,\r\n \/\/CUSTOMIZE: These are the default colors used for the confetti. You can change these numbers or add to them. \r\n \/\/CUSTOMIZE: Separate adding new colors by a comma after each new color added.\r\n COLORS : [\r\n \"#EF5350\",\r\n \"#EC407A\",\r\n \"#AB47BC\",\r\n \"#7E57C2\",\r\n \"#5C6BC0\",\r\n \"#42A5F5\",\r\n \"#29B6F6\",\r\n \"#26C6DA\",\r\n \"#26A69A\",\r\n \"#66BB6A\",\r\n \"#9CCC65\",\r\n \"#D4E157\",\r\n \"#FFEE58\",\r\n \"#FFCA28\",\r\n \"#FFA726\",\r\n \"#FF7043\",\r\n \"#8D6E63\",\r\n \"#BDBDBD\",\r\n \"#78909C\" ]\r\n };\r\n }\r\n \r\n build() {\r\n for (let i = 0; i < this.length; ++i) {\r\n let canvas = document.createElement(\"canvas\"),\r\n ctx = canvas.getContext(\"2d\");\r\n \r\n canvas.width = Confetti.CONST.SPRITE_WIDTH;\r\n canvas.height = Confetti.CONST.SPRITE_HEIGHT;\r\n \r\n canvas.position = {\r\n initX : Math.random() * this.width,\r\n initY : -canvas.height - Math.random() * this.yRange\r\n };\r\n \r\n canvas.rotation = (this.rotationRange \/ 2) - Math.random() * this.rotationRange;\r\n canvas.speed = (this.speedRange \/ 2) + Math.random() * (this.speedRange \/ 2);\r\n \r\n ctx.save();\r\n ctx.fillStyle = Confetti.CONST.COLORS[(Math.random() * Confetti.CONST.COLORS.length) | 0];\r\n ctx.fillRect(0, 0, canvas.width, canvas.height);\r\n ctx.restore();\r\n \r\n this.sprites.push(canvas);\r\n }\r\n }\r\n \r\n render(now) {\r\n let progress = this.progress.tick(now);\r\n \r\n this.canvas.width = this.width;\r\n this.canvas.height = this.height;\r\n \r\n for (let i = 0; i < this.length; ++i) {\r\n this.ctx.save();\r\n this.ctx.translate(\r\n this.sprites[i].position.initX + this.sprites[i].rotation * Confetti.CONST.ROTATION_RATE * progress,\r\n this.sprites[i].position.initY + progress * (this.height + this.yRange)\r\n );\r\n this.ctx.rotate(this.sprites[i].rotation);\r\n this.ctx.drawImage(\r\n this.sprites[i],\r\n -Confetti.CONST.SPRITE_WIDTH * Math.abs(Math.sin(progress * Math.PI * 2 * this.sprites[i].speed)) \/ 2,\r\n -Confetti.CONST.SPRITE_HEIGHT \/ 2,\r\n Confetti.CONST.SPRITE_WIDTH * Math.abs(Math.sin(progress * Math.PI * 2 * this.sprites[i].speed)),\r\n Confetti.CONST.SPRITE_HEIGHT\r\n );\r\n this.ctx.restore();\r\n }\r\n \r\n requestAnimationFrame(this.render);\r\n }\r\n}\r\n \r\n(() => {\r\n \/\/CUSTOMIZE: This will control the speed of how fast the confetti falls, raise the number for a slower fall.\r\n const DURATION = 8000,\r\n \/\/CUSTOMIZE: This number controls how much confetti will appear on the screen. For more confetti, raise the number.\r\n LENGTH = 120;\r\n \r\n new Confetti({\r\n width : window.innerWidth,\r\n height : window.innerHeight,\r\n length : LENGTH,\r\n duration : DURATION\r\n });\r\n \r\n setTimeout(() => {\r\n new Confetti({\r\n width : window.innerWidth,\r\n height : window.innerHeight,\r\n length : LENGTH,\r\n duration : DURATION\r\n });\r\n }, DURATION \/ 2);\r\n})();\r\n \r\n}\r\n <\/script>\r\n <?php\r\n}\r\nadd_action( 'wpforms_form_pages_footer', 'wpf_confetti_animation', 1);","note":"","categories":["wpforms"],"code_type":"js","needs_auth":false,"tags":["wpforms"],"max_version":""},{"library_id":33514,"title":"How to Add Material Design to Your Form Fields Using CSS","code":"\/**\r\n * Move label position from above form field to below\r\n *\r\n * @link https:\/\/wpforms.com\/developers\/how-to-add-material-design-to-your-form-fields-using-css\/\r\n *\/\r\n \r\nfunction wpf_dev_display_field_before( $field, $form_data ) {\r\n \r\n \/\/ Only run this snippet on form ID 697\r\n if ( absint( $form_data[ 'id' ] ) !== 697 ) {\r\n return;\r\n }\r\n \r\n \/\/ Remove the action that sets the label before the form field\r\n remove_action( 'wpforms_display_field_before', array( wpforms()->frontend, 'field_label' ), 15 );\r\n}\r\n \r\nadd_action( 'wpforms_display_field_before', 'wpf_dev_display_field_before', 10, 2 );\r\n \r\nfunction wpf_dev_display_field_after( $field, $form_data ) {\r\n \r\n \/\/ Only run this snippet on form ID 697\r\n if ( absint( $form_data[ 'id' ] ) !== 697 ) {\r\n return;\r\n }\r\n \r\n \/\/ Set the label to appear after the form field is displayed\r\n wpforms()->frontend->field_label( $field, $form_data );\r\n}\r\n \r\nadd_action( 'wpforms_display_field_after', 'wpf_dev_display_field_after', 10, 2 );","note":"","categories":["wpforms"],"code_type":"php","needs_auth":false,"tags":[],"max_version":""},{"library_id":33065,"title":"How to Automatically Redirect If User Is Already Logged In","code":"\/**\r\n * Automatic redirect from login form if a user is already logged in\r\n *\r\n * @link https:\/\/wpforms.com\/developers\/how-to-automatically-redirect-if-user-is-already-logged-in\/\r\n *\/\r\n \r\nfunction redirect_to_specific_page() {\r\n \r\n \/\/ enter the page ID of the page that contains the login form\r\n $page_id = 345; \/\/ Change page ID\r\n \r\n \/\/ if the user is on the login form page and the user is logged in then redirect\r\n if ( is_page($page_id) && is_user_logged_in() && ! current_user_can('edit_post', $post_id) ) {\r\n \r\n \/\/ enter the URL of the page you would like to redirect them to\r\n wp_redirect( 'http:\/\/www.example-site.com\/your-page\/', 301 ); \r\n \r\n exit;\r\n }\r\n}\r\nadd_action( 'template_redirect', 'redirect_to_specific_page' );","note":"","categories":["wpforms"],"code_type":"php","needs_auth":false,"tags":[],"max_version":""},{"library_id":33052,"title":"How to Automatically Submit a Form with a Field Choice","code":"\/**\r\n * Trigger submit from checkbox click\r\n *\r\n * @link https:\/\/wpforms.com\/developers\/how-to-automatically-submit-a-form-with-a-field-choice\/\r\n *\/\r\n \r\nfunction wpf_dev_automatic_submit_form( ) {\r\n?>\r\n \r\n<script type=\"text\/javascript\">\r\n \r\njQuery(function($){\r\n \r\n var event = jQuery.Event( \"submit\" );\r\n \r\n jQuery(\"input:checkbox\").change(\r\n function()\r\n {\r\n \/\/ when any checkbox is checked, trigger this function\r\n if( jQuery(this).is(\":checked\") )\r\n {\r\n \/\/ only run this function for the form ID 3046\r\n jQuery(\"#wpforms-form-3046\").submit();\r\n }\r\n }\r\n )\r\n \r\n });\r\n \r\n <\/script>\r\n \r\n<?php\r\n}\r\n \r\nadd_action( 'wpforms_wp_footer_end', 'wpf_dev_automatic_submit_form', 30 );","note":"","categories":["wpforms"],"code_type":"php","needs_auth":false,"tags":[],"max_version":""},{"library_id":33053,"title":"How to Automatically Submit a Form with a Field Choice - CSS","code":"button#wpforms-submit-3046 {\r\n display: none;\r\n}\r\n \r\nform#wpforms-form-3046 span.wpforms-icon-choices-label {\r\n font-size: 0;\r\n}\r\n \r\nul#wpforms-3046-field_3 li label:hover, ul#wpforms-3046-field_4 li label:hover, ul#wpforms-3046-field_3 li.wpforms-selected label, ul#wpforms-3046-field_4 li.wpforms-selected label {\r\n box-shadow: none;\r\n}\r\n \r\nform#wpforms-form-3046 ul.wpforms-icon-choices .wpforms-icon-choices-item label{\r\n margin:0 auto;\r\n padding:0;\r\n}\r\n \r\ndiv#wpforms-3046-field_4-container {\r\n width: 20%;\r\n float: left;\r\n}\r\n \r\ndiv#wpforms-3046-field_3-container {\r\n width: 20%;\r\n float: right;\r\n}\r\n \r\n@media screen and (max-width: 600px) {\r\n \r\ndiv#wpforms-3046-field_4-container {\r\n width: 50%;\r\n float: left;\r\n}\r\n \r\ndiv#wpforms-3046-field_3-container {\r\n width: 50%;\r\n float: right;\r\n}\r\n \r\nform#wpforms-form-3046 .wpforms-layout-column {\r\n width: 50%;\r\n}\r\n \r\nform#wpforms-form-3046 .wpforms-field-layout-columns {\r\n flex-direction: unset;\r\n }\r\n \r\n}","note":"","categories":["wpforms"],"code_type":"css","needs_auth":false,"tags":[],"max_version":""},{"library_id":35398,"title":"How to Block Names From Completing Your Form - First Last and First Middle Last format","code":"\/**\r\n * Prevent certain names from the other formats for the Name form field.\r\n *\r\n * @link https:\/\/wpforms.com\/developers\/how-to-block-names-from-completing-your-form\/\r\n *\/\r\n \r\nfunction wpf_dev_block_name_validation( $field_id, $field_submit, $form_data ) {\r\n \r\n \/\/ Bail early if form ID is not 1000 and field ID is not 10\r\n if ( absint( $form_data[ 'id' ] ) !== 1000 || absint( $field_id ) !== 10 ) {\r\n return;\r\n }\r\n\r\n \/\/ Form builder Name format is set to First Last\r\n $submitted_name = $field_submit[ 'first' ] .' ' .$field_submit[ 'last' ];\r\n\r\n \/\/ Create your list of names to be blocked separated by commas\r\n $blocked_names = array(\r\n 'John Doe', \r\n 'Jane Doe',\r\n 'Jack Doe'\r\n );\r\n\r\n foreach( $blocked_names as $name ) {\r\n if( preg_match( '\/\\b' .$name. '\\b\/i',$submitted_name) ) {\r\n wpforms()->process->errors[ $form_data[ 'id' ] ][ 'header' ] = esc_html__( 'Can\\'t submit form. Please try again later.', 'wpforms' );\r\n return;\r\n }\r\n }\r\n\r\n}\r\n\r\nadd_action( 'wpforms_process_validate_name', 'wpf_dev_block_name_validation', 10, 3 );\r\n","note":"","categories":["wpforms"],"code_type":"php","needs_auth":false,"tags":["wpforms"],"max_version":""},{"library_id":35397,"title":"How to Block Names From Completing Your Form - Simple format","code":"\/**\r\n * Prevent certain names from the Simple format Name form field.\r\n *\r\n * @link https:\/\/wpforms.com\/developers\/how-to-block-names-from-completing-your-form\/\r\n *\/\r\n\r\nfunction wpf_dev_block_name_validation( $field_id, $field_submit, $form_data ) {\r\n\r\n \/\/ Bail early if form ID is not 1000 and field ID is not 10\r\n if ( absint( $form_data[ 'id' ] ) !== 1000 || absint( $field_id ) !== 10 ) {\r\n return;\r\n }\r\n\r\n \/\/ Create your list of blocked names separated by commas\r\n $blocked_names = array( \r\n 'Jane Doe', \r\n\t\t'John Doe',\r\n 'Jack Doe'\r\n );\r\n \r\n foreach( $blocked_names as $name ) {\r\n if(strpos($field_submit, $name) !== FALSE ) {\r\n wpforms()->process->errors[ $form_data[ 'id' ] ][ $field_id ] = esc_html__( 'Can\\'t submit form. Please try again later.', 'wpforms' );\r\n return;\r\n }\r\n }\r\n\t\r\n}\r\n\r\nadd_action( 'wpforms_process_validate_name', 'wpf_dev_block_name_validation', 10, 3 );","note":"","categories":["wpforms"],"code_type":"php","needs_auth":false,"tags":["wpforms"],"max_version":""},{"library_id":32143,"title":"How to Build a Profile Page Using Post Submissions","code":"\/**\r\n * Add a profile form using Post Submissions\r\n *\r\n * @link https:\/\/wpforms.com\/developers\/how-to-build-an-profile-form-using-post-submissions\/\r\n *\/\r\n \r\nfunction wpf_post_submission_custom_content( $post_id, $fields, $form_data, $entry_id ) {\r\n \r\n \/\/ Only do this for form #1089.\r\n if ( absint( $form_data[ 'id' ] ) !== 1089 ) {\r\n return;\r\n }\r\n \r\n \/*\r\n * Field IDs, for reference.\r\n * 15 - Birthday\r\n * 16 - \"My friends would describe me as\"\r\n * 18 - \"The most influential person in my life has been...\"\r\n * 19 - \"Five things I couldn't live without\"\r\n *\/\r\n \r\n \/\/ Below we're going to create our new custom content template,\r\n \/\/ using the field IDs listed above :)\r\n ob_start();\r\n ?>\r\n \r\n <h2><em><?php echo __('Author Profile', 'text-domain'); ?><\/em><\/h2>\r\n \r\n <h3><?php echo __('Name', 'text-domain'); ?><\/h3>\r\n <?php echo wpautop( esc_html( $fields[2][ 'value' ] ) ); ?>\r\n \r\n <h3><?php echo __('Birthday', 'text-domain'); ?><\/h3>\r\n <?php echo wpautop( esc_html( $fields[15][ 'value' ] ) ); ?>\r\n \r\n <h3><?php echo __('My friends would describe me as', 'text-domain'); ?><\/h3>\r\n <?php echo wpautop( esc_html( $fields[16][ 'value' ] ) ); ?>\r\n \r\n <h3><?php echo __('The most influential person in my life has been...', 'text-domain'); ?><\/h3>\r\n <?php echo wpautop( esc_html( $fields[18][ 'value' ] ) ); ?>\r\n \r\n <h3><?php echo __('Five things I couldn\\'t live without', 'text-domain'); ?><\/h3>\r\n <?php echo wpautop( esc_html( $fields[19][ 'value' ] ) ); ?>\r\n \r\n <?php\r\n $content = ob_get_clean();\r\n \r\n remove_filter('content_save_pre', 'wp_filter_post_kses');\r\n remove_filter('content_filtered_save_pre', 'wp_filter_post_kses');\r\n \r\n $post = array(\r\n 'ID' => $post_id,\r\n 'post_content' => $content,\r\n );\r\n wp_update_post( $post );\r\n \r\n add_filter('content_save_pre', 'wp_filter_post_kses');\r\n add_filter('content_filtered_save_pre', 'wp_filter_post_kses');\r\n}\r\nadd_action( 'wpforms_post_submissions_process', 'wpf_post_submission_custom_content', 10, 4 );","note":"With this snippet and the Post Submissions addon, you can create professional author profiles that...","categories":["wpforms"],"code_type":"php","needs_auth":false,"tags":["wpforms"],"max_version":""},{"library_id":31675,"title":"How to Center a Form","code":".wpforms-container.wpf-center {\r\n margin: 0 auto !important;\r\n \/* Adjust the width in the next 2 lines as your site needs *\/\r\n max-width: 500px !important;\r\n width: 500px !important;\r\n}\r\n\r\n\/* Readjust the form width for smaller devices *\/\r\n@media only screen and (max-width: 600px) {\r\n .wpforms-container.wpf-center {\r\n \/* Reset the width for devices under 600px *\/\r\n max-width: unset !important;\r\n width: auto !important;\r\n }\r\n}","note":"This code centers the form using margin: 0 auto and sets a maximum width of...","categories":["wpforms"],"code_type":"css","needs_auth":false,"tags":["wpforms"],"max_version":""},{"library_id":35400,"title":"How to Change Google reCAPTCHA Language Settings","code":"\/**\r\n* Set a specific language Google reCAPTCHA.\r\n*\r\n* @link https:\/\/wpforms.com\/developers\/how-to-set-the-language-for-google-recaptcha\/\r\n*\/\r\n\r\nfunction wpf_dev_recaptcha_language_wpml( $url ) {\r\n\t\r\n\t\/\/ Get my current language setting from WPML\r\n\t$my_current_lang = apply_filters( 'wpml_current_language', NULL );\r\n\t\r\n\t\/\/ Set the language of my Google reCAPTCHA to the same language that I have set in WPML\r\n\treturn esc_url_raw( add_query_arg( array( 'hl' => $my_current_lang ), $url ) );\r\n\t\r\n}\r\n\r\nadd_filter('wpforms_frontend_recaptcha_url', 'wpf_dev_recaptcha_language_wpml', 10, 1);","note":"WPML support","categories":["wpforms"],"code_type":"php","needs_auth":false,"tags":["wpforms"],"max_version":""},{"library_id":33044,"title":"How to Change the Captcha Theme on Google Checkbox v2 reCAPTCHA","code":"\/**\r\n * Change the captcha theme for the Google Checkbox v2 reCAPTCHA\r\n *\r\n * @link https:\/\/wpforms.com\/developers\/how-to-change-the-captcha-theme-on-google-checkbox-v2-recaptcha\/\r\n *\/\r\n \r\nfunction wpf_dev_change_captcha_theme() {\r\n ?>\r\n <script type=\"text\/javascript\">\r\n jQuery(function($) {\r\n \r\n $( '.g-recaptcha' ).attr( 'data-theme', 'dark' );\r\n });\r\n \r\n <\/script>\r\n <?php\r\n}\r\nadd_action('wpforms_wp_footer_end', 'wpf_dev_change_captcha_theme', 30);","note":"","categories":["wpforms"],"code_type":"php","needs_auth":false,"tags":["wpforms"],"max_version":""},{"library_id":31683,"title":"How to Change the Error Text for Failed Submissions","code":"\/**\r\n* Change the error text message that appears.\r\n*\r\n* @link https:\/\/wpforms.com\/developers\/how-to-change-the-error-text-for-failed-submissions\/\r\n*\/\r\nfunction wpf_translated($translated_text, $text, $domain) {\r\n \/\/ Bail early if it's not a WPForms string.\r\n if ($domain !== 'wpforms-lite') {\r\n return $translated_text;\r\n }\r\n\r\n \/\/ Compare against the original string (in English).\r\n if ($text === 'Form has not been submitted, please see the errors below.') {\r\n $translated_text = __('Hey! Please check under the hood!', 'wpforms');\r\n }\r\n\r\n return $translated_text;\r\n}\r\nadd_filter('gettext', 'wpf_translated', 10, 3);","note":"This code snippet changes the error text that shows to your visitors on failed submissions.","categories":["wpforms"],"code_type":"php","needs_auth":false,"tags":["wpforms"],"max_version":""},{"library_id":35017,"title":"How to Conditionally Show the Next Button on a Specific Page","code":"\/**\r\n * Hide Next button on page 2 by default and show it once an option in a field (e.g. Multiple Choice) is selected.\r\n *\/\r\n\r\n\/\/ Add CSS to hide the Next button on page 2.\r\nadd_action( 'wp_head', function () { ?>\r\n <style> \r\n \/* Hide Next button on page 2 *\/\r\n #wpforms-form-1000 button.wpforms-page-button.wpforms-page-next[data-page=\"2\"] {\r\n display: none; \r\n }\r\n\r\n \/* Class to show Next button once an option is selected *\/ \r\n #wpforms-form-1000 button.wpforms-page-button.wpforms-page-next[data-page=\"2\"].show-next {\r\n display: inline-block;\r\n }\r\n <\/style>\r\n<?php } );\r\n\r\n\/\/ Add JS to show the Next button after an option is selected in the field.\r\nadd_action( 'wpforms_wp_footer_end', function() { ?> \r\n <script>\r\n jQuery(function($){\r\n var formSelector = \"#wpforms-form-1000\"; \r\n \/\/ Listen for changes in the field with ID 10.\r\n $(formSelector).on('change', \"input[name='wpforms[fields][10]']\", function(){ \r\n var selectedval = $(formSelector + \" input[name='wpforms[fields][10]']:checked\").val();\r\n if (selectedval) {\r\n \/\/ If an option is selected, add the show-next class to the Next button on page 2.\r\n $(formSelector + \" .wpforms-page-button.wpforms-page-next[data-page='2']\").addClass(\"show-next\"); \r\n }\r\n });\r\n });\r\n <\/script>\r\n<?php } );","note":"","categories":["wpforms"],"code_type":"php","needs_auth":false,"tags":["wpforms"],"max_version":""},{"library_id":33510,"title":"How to Create a Form With Floating Labels","code":"\/**\r\n * Remove the field label from the top of the field\r\n *\r\n * @link https:\/\/wpforms.com\/developers\/how-to-create-a-form-with-floating-labels\/\r\n *\/\r\n \r\nfunction wpf_dev_display_field_before( $field, $form_data ) {\r\n \r\n \/\/ Only run this snippet on the form ID 1289\r\n if ( absint( $form_data[ 'id' ] ) !== 1289 ) {\r\n return;\r\n }\r\n \r\n remove_action( 'wpforms_display_field_before', array( wpforms()->frontend, 'field_label' ), 15 );\r\n}\r\n \r\nadd_action( 'wpforms_display_field_before', 'wpf_dev_display_field_before', 10, 2 );\r\n \r\n\/**\r\n * Move the field label to below the field\r\n *\r\n * @link https:\/\/wpforms.com\/developers\/how-to-create-a-form-with-floating-labels\/\r\n *\/\r\n \r\nfunction wpf_dev_display_field_after( $field, $form_data ) {\r\n \r\n \/\/ Only run this snippet on the form ID 1289\r\n if ( absint( $form_data[ 'id' ] ) !== 1289 ) {\r\n return;\r\n }\r\n \r\n wpforms()->frontend->field_label( $field, $form_data );\r\n}\r\n \r\nadd_action( 'wpforms_display_field_after', 'wpf_dev_display_field_after', 1, 2 );","note":"","categories":["wpforms"],"code_type":"php","needs_auth":false,"tags":[],"max_version":""},{"library_id":33057,"title":"How to Customize the Labels for Image Choices","code":"\/* Position labels over images and hide them by default *\/\r\nform#wpforms-form-1000 .wpforms-field .wpforms-image-choices-label {\r\n position: absolute;\r\n top: 0;\r\n left: 0;\r\n width: 100%;\r\n height: 100%;\r\n background-color: rgba(255, 255, 255, 0.7);\r\n text-align: center;\r\n display: flex;\r\n justify-content: center;\r\n align-items: center;\r\n opacity: 0;\r\n transition: opacity 0.3s ease-in-out;\r\n}\r\n\r\n\/* Show labels on hover *\/\r\nform#wpforms-form-1000 .wpforms-field .wpforms-image-choices-item:hover .wpforms-image-choices-label {\r\n opacity: 1;\r\n}","note":"","categories":["wpforms"],"code_type":"css","needs_auth":false,"tags":[],"max_version":""},{"library_id":33058,"title":"How to Customize the Labels for Image Choices - Combined effect","code":"form#wpforms-form-1000 .wpforms-field .wpforms-image-choices-item:hover .wpforms-image-choices-label {\r\n position: absolute;\r\n top: 0;\r\n left: 50%;\r\n transform: translateX(-50%);\r\n background-color: #f6f6f6;\r\n color: #333;\r\n padding: 20%;\r\n border-radius: 5px;\r\n opacity: 1;\r\n transition: opacity 0.3s ease-in-out;\r\n width: 100%;\r\n height: 100%;\r\n}\r\n \r\nform#wpforms-form-1000 .wpforms-image-choices label:hover {\r\n border: none;\r\n box-shadow: none;\r\n}\r\n \r\nform#wpforms-form-1000 span.wpforms-image-choices-label {\r\n visibility: hidden;\r\n height: 0;\r\n padding: 0;\r\n}\r\n \r\nform#wpforms-form-1000 .wpforms-field .wpforms-image-choices-item:hover span.wpforms-image-choices-label {\r\n visibility: visible;\r\n}","note":"","categories":["wpforms"],"code_type":"css","needs_auth":false,"tags":[],"max_version":""},{"library_id":32586,"title":"How to Customize the Rich Text Field TinyMCE Icons","code":"\/**\r\n * Customize Rich Text Field TinyMCE buttons for top toolbar.\r\n *\r\n * @link https:\/\/wpforms.com\/developers\/how-to-customize-the-rich-text-field-tinymce-icons\/\r\n *\/\r\n \r\n\/\/ Function to change the top toolbar\r\nfunction wpf_dev_customize_tinymce_buttons_toolbar1( $toolbar, $field_id, $field_data ) {\r\n \r\n $toolbar = [\r\n 'fontselect',\r\n 'fontsizeselect',\r\n 'forecolor',\r\n 'indent',\r\n 'outdent',\r\n 'italic',\r\n 'styleselect',\r\n 'strikethrough',\r\n 'subscript',\r\n 'superscript',\r\n 'underline',\r\n 'charmap',\r\n 'hr',\r\n 'link',\r\n 'wp_more',\r\n 'wp_adv',\r\n ];\r\n \r\n return $toolbar;\r\n}\r\nadd_filter( 'wpforms_richtext_get_toolbar1', 'wpf_dev_customize_tinymce_buttons_toolbar1', 10, 3 );\r\n \r\n\/**\r\n * Customize Rich Text Field TinyMCE buttons for bottom toolbar.\r\n *\r\n * @link https:\/\/wpforms.com\/developers\/how-to-customize-the-rich-text-field-tinymce-icons\/\r\n *\/\r\n \r\n\/\/ Function to change the top toolbar\r\nfunction wpf_dev_customize_tinymce_buttons_toolbar2( $toolbar, $field_id, $field_data ) {\r\n \r\n $toolbar = [\r\n 'wp_help',\r\n 'aligncenter',\r\n 'alignjustify',\r\n 'alignleft',\r\n 'alignnone',\r\n 'alignright',\r\n 'blockquote',\r\n 'backcolor',\r\n 'bold',\r\n 'copy',\r\n 'cut',\r\n 'paste',\r\n 'bullist',\r\n 'numlist',\r\n 'undo',\r\n 'redo',\r\n 'remove',\r\n 'removeformat',\r\n 'selectall',\r\n ];\r\n \r\n return $toolbar;\r\n}\r\nadd_filter( 'wpforms_richtext_get_toolbar2', 'wpf_dev_customize_tinymce_buttons_toolbar2', 10, 3 );\r\n","note":"","categories":["wpforms"],"code_type":"php","needs_auth":false,"tags":["wpforms"],"max_version":""},{"library_id":33048,"title":"How to Defer the reCAPTCHA Script","code":"\/**\r\n * Defer the reCAPTCHA script until after the page loads\r\n *\r\n * @link https:\/\/wpforms.com\/developers\/how-to-defer-the-recaptcha-script\/\r\n *\/\r\n \r\nfunction wpf_recaptcha_add_async_defer( $tag, $handle ) {\r\n \r\n if ( strpos( $tag, 'recaptcha\/api.js?onload=wpformsRecaptchaLoad' ) !== false ) {\r\n $tag = str_replace( ' src', ' defer async=\"async\" src', $tag );\r\n }\r\n \r\n return $tag;\r\n \r\n }\r\n \r\nadd_filter( 'script_loader_tag', 'wpf_recaptcha_add_async_defer', 99, 2 );","note":"","categories":["wpforms"],"code_type":"php","needs_auth":false,"tags":["wpforms"],"max_version":""},{"library_id":33059,"title":"How to Disable Browser Autocomplete for Form Fields - all fields","code":"\/**\r\n * Disable form autocomplete for all fields on a specific form \r\n *\r\n * @link https:\/\/wpforms.com\/developers\/disable-browser-autocomplete-for-form-fields\/\r\n *\/\r\n\r\nfunction wpf_dev_disable_form_autocomplete( $form_atts, $form_data ) {\r\n \r\n \/\/ This check will only form autocomplete for Form #11.\r\n \/\/ Removing this check would disable autocomplete on ALL forms.\r\n \r\n if ( absint( $form_data[ 'id' ] ) !== 1277 ) {\r\n return $form_atts;\r\n }\r\n \r\n $form_atts[ 'atts' ][ 'autocomplete' ] = 'off';\r\n \r\n return $form_atts;\r\n}\r\n \r\nadd_filter( 'wpforms_frontend_form_atts', 'wpf_dev_disable_form_autocomplete', 10, 2 );","note":"","categories":["wpforms"],"code_type":"php","needs_auth":false,"tags":[],"max_version":""},{"library_id":33060,"title":"How to Disable Browser Autocomplete for Form Fields - specific fields","code":"\/**\r\n * Disable autocomplete for a specific form and field ID\r\n *\r\n * @link https:\/\/wpforms.com\/developers\/disable-browser-autocomplete-for-form-fields\/\r\n *\/\r\n \r\nfunction wpf_disable_email_autocomplete( $properties, $field, $form_data ) {\r\n \r\n \/\/ This check will only disable autocomplete for Field #3 inside Form #11.\r\n \/\/ Removing this check would disable autocomplete on ALL fields.\r\n if ( absint( $form_data[ 'id' ] ) !== 11 && absint( $field[ 'id' ] ) !== 3 ) {\r\n return $properties;\r\n }\r\n \r\n $properties[ 'inputs' ][ 'primary' ][ 'attr' ][ 'autocomplete' ] = 'off';\r\n \r\n return $properties;\r\n}\r\n \r\nadd_filter( 'wpforms_field_properties_email', 'wpf_disable_email_autocomplete', 10, 3 );","note":"","categories":["wpforms"],"code_type":"php","needs_auth":false,"tags":[],"max_version":""},{"library_id":32587,"title":"How to Disable reCAPTCHA for Automated Testing","code":"\/**\r\n * Disable for automated testing.\r\n *\r\n * @link https:\/\/wpforms.com\/developers\/how-to-disable-recaptcha-for-automated-testing\/\r\n *\/\r\n \r\n \/\/ Disable reCAPTCHA assets and initialisation on the frontend.\r\n add_filter( 'wpforms_frontend_recaptcha_disable', '__return_true' );\r\n \r\n \/\/ Disable validation and verification on the backend.\r\n add_filter( 'wpforms_process_bypass_captcha', '__return_true' );","note":"","categories":["wpforms"],"code_type":"php","needs_auth":false,"tags":["wpforms"],"max_version":""},{"library_id":31684,"title":"How to Display a List of WPForms Using a Shortcode","code":"\/**\r\n* Create shortcode to display all form titles in a list.\r\n*\r\n* Basic usage: [wpforms_all_forms]\r\n*\r\n* @link https:\/\/wpforms.com\/developers\/how-to-display-a-list-of-wpforms-using-a-shortcode\/\r\n*\/\r\nadd_shortcode('wpforms_all_forms', function() {\r\n $args = [\r\n 'post_type' => 'wpforms',\r\n 'post_status' => 'publish',\r\n 'posts_per_page' => -1,\r\n ];\r\n\r\n $posts = wpforms()->form->get();\r\n $forms = wp_list_pluck($posts, 'post_title');\r\n return implode('<br>', $forms);\r\n});","note":"This snippet will create a new shortcode that can display all your WPForms forms.","categories":["wpforms"],"code_type":"php","needs_auth":false,"tags":["wpforms"],"max_version":""},{"library_id":32163,"title":"How to Display Hidden Single Item Fields in Order Summary","code":"\/**\r\n * Display Hidden Single Item Fields in Order Summary\r\n *\r\n * @link https:\/\/wpforms.com\/developers\/how-to-display-hidden-single-item-fields-in-order-summary\r\n *\/\r\nfunction wpf_include_singleitem_hiddentype_include_in_order_summary_footer($foot) {\r\n \/\/ replace the 1000 with your Form ID\r\n $form_data = wpforms()->form->get( 1000, [ 'content_only' => true ] ); \/\/ Replace with actual method to get your form data if needed\r\n\r\n \/\/ Loop through form fields to find hidden payment-single fields\r\n foreach ($form_data['fields'] as $field_id => $field) {\r\n if ($field['type'] === 'payment-single' && isset($field['format']) && $field['format'] === 'hidden') {\r\n \/\/ Get price for hidden items\r\n $price = !empty($field['price']) ? wpforms_sanitize_amount($field['price']) : 0;\r\n\r\n $foot[] = [\r\n 'label' => isset($field['label']) ? sanitize_text_field($field['label']) : __('Hidden Item', 'your-text-domain'),\r\n 'quantity' => 1, \/\/ Adjust quantity logic as needed\r\n 'amount' => wpforms_format_amount($price, true),\r\n 'class' => 'wpforms-order-summary-hidden-item',\r\n ];\r\n }\r\n }\r\n\r\n return $foot;\r\n}\r\n\r\nadd_filter('wpforms_forms_fields_payment_total_field_order_summary_preview_foot', 'wpf_include_singleitem_hiddentype_include_in_order_summary_footer');\r\n\r\nfunction wpf_include_singleitem_hiddentype_in_order_summary($fields, $entry, $form_data) {\r\n $payment_fields = wpforms_payment_fields(); \/\/ Retrieve all payment-related fields, typically available in WPForms.\r\n\r\n foreach ($form_data['fields'] as $id => $field) {\r\n if (in_array($field['type'], $payment_fields, true) && $field['type'] === 'payment-single' && isset($field['format']) && $field['format'] === 'hidden') {\r\n \/\/ Calculate price only if the format is hidden\r\n $price = !empty($field['price']) ? wpforms_sanitize_amount($field['price']) : 0;\r\n\r\n $fields[$id] = [\r\n 'name' => sanitize_text_field($field['label']),\r\n 'value' => wpforms_format_amount($price, true),\r\n 'amount' => wpforms_format_amount($price),\r\n 'amount_raw' => $price,\r\n 'type' => 'payment-single-hidden',\r\n ];\r\n }\r\n }\r\n\r\n return $fields;\r\n}\r\n\r\nadd_filter('wpforms_forms_fields_payment_total_field_order_summary', 'wpf_include_singleitem_hiddentype_in_order_summary', 10, 3);","note":"This code snippet will display the hidden single item field in order summary","categories":["wpforms"],"code_type":"php","needs_auth":false,"tags":["wpforms"],"max_version":""},{"library_id":35396,"title":"How to Get the URL from the File Upload Form Field","code":"\/**\r\n * Get and use the File Upload field URL \r\n *\r\n * @link https:\/\/wpforms.com\/developers\/how-to-get-the-url-from-the-file-upload-form-field\/\r\n *\/\r\n \r\nfunction wpf_dev_frontend_confirmation_message( $message, $form_data, $fields, $entry_id ) {\r\n \r\n \/\/ Only run on my form with ID = 1000\r\n if ( absint( $form_data[ 'id' ] ) !== 1000 ) {\r\n return $message;\r\n }\r\n \r\n \/\/ Grab the URL of the single image uploaded to the form\r\n $myfileurl = $fields[ '10' ][ 'value' ];\r\n\t\r\n\t\/\/ Echo out the image under the confirmation message\r\n\t$image .= '<div class=\"image_container\"><img src=\"' . $myfileurl . '\" class=\"small\"><\/div>';\r\n \r\n $message = '<p>' . esc_html__( 'Thank you for your submission. Below is the image you uploaded for our contest. Watch your email for the winner to be notified on July 31st.', 'plugin-domain' ) . '<\/p>';\r\n \r\n return $message . '<p>' . $image . '<\/p>';\r\n \r\n}\r\nadd_filter( 'wpforms_frontend_confirmation_message', 'wpf_dev_frontend_confirmation_message', 10, 4 );","note":"","categories":["wpforms"],"code_type":"php","needs_auth":false,"tags":["wpforms"],"max_version":""},{"library_id":30559,"title":"How to Hide Zero Quantity Items in Dropdown Payment Field Notifications","code":"\/**\r\n * Hiding Zero Quantity Items in Email Notifications for Payment Fields\r\n *\r\n * @link https:\/\/wpforms.com\/developers\/how-to-hide-zero-quantity-items-in-dropdown-payment-field-notifications\r\n *\/\r\nadd_filter('wpforms_entry_email_data', function ($fields, $entry, $form_data) {\r\n foreach ($fields as $field_id => $field) {\r\n \/\/ Adjust to handle 'payment-single', 'payment-select', or any other types\r\n if (\r\n isset($form_data['fields'][$field_id]['type']) && \r\n in_array($form_data['fields'][$field_id]['type'], ['payment-select', 'payment-single'])\r\n ) {\r\n $quantity = isset($field['quantity']) ? (int) $field['quantity'] : 0;\r\n\r\n if ($quantity == 0) {\r\n unset($fields[$field_id]);\r\n }\r\n }\r\n }\r\n\r\n return $fields;\r\n}, 10, 3); ","note":"This snippet hides items with zero quantities from your WPForms notification emails when using payment...","categories":["wpforms"],"code_type":"php","needs_auth":false,"tags":[],"max_version":""},{"library_id":31679,"title":"How to Link Your Conversational Form Logo","code":"\/**\r\n* Link your form logo on conversational forms.\r\n*\r\n* @link https:\/\/wpforms.com\/developers\/how-to-link-your-conversational-form-logo\r\n*\/\r\nfunction wpf_dev_conversational_form_add_link() {\r\n ?>\r\n <script type=\"text\/javascript\">\r\n jQuery(function($) {\r\n var formID = 375; \/\/ ID of conversational form to which applies\r\n \r\n if ($('#wpforms-' + formID).length === 0) {\r\n return;\r\n }\r\n \r\n \/\/ Detect Conversational Form image.\r\n var $logo = $('#wpforms-conversational-form-page').find('.wpforms-conversational-form-logo');\r\n if ($logo.length > 0) {\r\n $logo.wrap($('<a>', {\r\n href: '\/' \/\/ \"\/\" could be changed to any link.\r\n }));\r\n }\r\n });\r\n <\/script>\r\n <?php\r\n}\r\nadd_action('wpforms_wp_footer', 'wpf_dev_conversational_form_add_link');","note":"This code snippet will make the logo clickable in a WPForms Conversational Form.","categories":["wpforms"],"code_type":"php","needs_auth":false,"tags":["wpforms"],"max_version":""},{"library_id":33047,"title":"How to Move to the Next Page Automatically","code":"\/**\r\n * Navigate to the next page automatically\r\n *\r\n * @link https:\/\/wpforms.com\/developers\/how-to-move-to-the-next-page-automatically\/\r\n *\/\r\n \r\nfunction wpf_dev_automatic_next_page( ) {\r\n?>\r\n \r\n<script type=\"text\/javascript\">\r\n jQuery(function() {\r\n jQuery( \"form#wpforms-form-1000 ul.wpforms-image-choices input\" ).click(function() {\r\n \r\n jQuery(this).closest( '.wpforms-page' ).find( '.wpforms-page-next' ).click();\r\n \r\n });\r\n \r\n });\r\n<\/script>\r\n \r\n<?php\r\n}\r\n \r\nadd_action( 'wpforms_wp_footer_end', 'wpf_dev_automatic_next_page', 30 );","note":"","categories":["wpforms"],"code_type":"js","needs_auth":false,"tags":["wpforms"],"max_version":""},{"library_id":33056,"title":"How to Perform Field Comparisons Within Your WPForms","code":"\/**\r\n * Perform Field Comparisons\r\n *\r\n * @link https:\/\/wpforms.com\/developers\/how-to-perform-field-comparisons-within-your-wpforms\/\r\n *\/\r\n \r\nfunction wpf_dev_compare_fields( $fields, $entry, $form_data ) {\r\n \r\n \/\/ Only run this snippet on the form ID 1000\r\n if ( absint( $form_data[ 'id' ] ) !== 1000 ) {\r\n return $fields;\r\n }\r\n \r\n \/\/ Enter the field ID for the first phone number\r\n $phone_1 = $fields[3][ 'value' ];\r\n \r\n \/\/ Enter the field ID for the second phone number\r\n $phone_2 = $fields[4][ 'value' ];\r\n \r\n \/\/ Regex pattern to match a simple 10-digit phone number\r\n $pattern = '\/^\\d{10}$\/';\r\n \r\n \/\/ Now check if both phone numbers match the pattern\r\n if ( !preg_match( $pattern, $phone_1 ) || !preg_match( $pattern, $phone_2 ) || $phone_1 !== $phone_2 ) {\r\n wpforms()->process->errors[$form_data[ 'id' ]][ 'header' ] = esc_html__( 'Your phone number must be the same in both fields.', 'wpforms' );\r\n }\r\n \r\n}\r\nadd_action( 'wpforms_process', 'wpf_dev_compare_fields', 10, 3 );","note":"","categories":["wpforms"],"code_type":"php","needs_auth":false,"tags":[],"max_version":""},{"library_id":32590,"title":"How to Populate a Form Field from an Anchor Link","code":"\/**\r\n * Populate field from anchor link.\r\n *\r\n * @link https:\/\/wpforms.com\/developers\/how-to-populate-a-form-field-from-an-anchor-link\/\r\n *\/\r\n \r\nfunction wpf_dev_autofill_field() {\r\n?>\r\n<script type=\"text\/javascript\">\r\n jQuery(document).ready(function(){\r\n jQuery( 'a[data-id=\"#daily\"]' ).click(function(){\r\n document.getElementById( 'wpforms-378-field_3' ).value = \"daily cleaning\";\r\n }); \r\n jQuery( 'a[data-id=\"#weekly\"]' ).click(function(){\r\n document.getElementById( 'wpforms-378-field_3' ).value = \"weekly cleaning\";\r\n }); \r\n jQuery( 'a[data-id=\"#monthly\"]' ).click(function(){\r\n document.getElementById( 'wpforms-378-field_3' ).value = \"monthly cleaning\";\r\n }); \r\n jQuery( 'a[data-id=\"#quarterly\"]' ).click(function(){\r\n document.getElementById( 'wpforms-378-field_3' ).value = \"quarterly cleaning\";\r\n }); \r\n });\r\n<\/script>\r\n \r\n<?php\r\n}\r\nadd_action( 'wpforms_wp_footer_end', 'wpf_dev_autofill_field', 10 );","note":"","categories":["wpforms"],"code_type":"php","needs_auth":false,"tags":["wpforms"],"max_version":""},{"library_id":32584,"title":"How to Restrict Countries Inside Smart Phone Form Fields","code":"\/**\r\n * Restrict countries inside the Smart Phone form field\r\n *\r\n * @link https:\/\/wpforms.com\/how-to-restrict-countries-inside-smart-phone-form-fields\/\r\n *\/\r\n \r\nfunction wpf_dev_smart_phone_field_restrict_countries() {\r\n ?>\r\n \r\n <script type=\"text\/javascript\">\r\n jQuery(document).on('wpformsReady', function () {\r\n jQuery('.wpforms-smart-phone-field').each(function () {\r\n var $el = jQuery(this),\r\n iti = $el.data('plugin_intlTelInput'),\r\n options;\r\n \r\n if (!iti) {\r\n return;\r\n }\r\n \r\n \/\/ Retrieve options based on the provided instance.\r\n if (iti.s) {\r\n options = Object.assign({}, iti.s);\r\n } else if (iti.options) {\r\n options = Object.assign({}, iti.options);\r\n } else {\r\n return;\r\n }\r\n \r\n $el.intlTelInput('destroy');\r\n \r\n \/\/ Set the only countries to US, UK and Canada\r\n options.onlyCountries = ['us', 'ca', 'gb']; \/\/ 'us' for United States, 'ca' for Canada, 'gb' for United Kingdom\r\n \r\n \/\/ Put a country code here according to this list: https:\/\/en.wikipedia.org\/wiki\/ISO_3166-1_alpha-2\r\n \r\n \/\/ Set initial country if needed\r\n options.initialCountry = 'us';\r\n \r\n \/\/ Re-initialize the plugin with the updated options\r\n $el.intlTelInput(options);\r\n \r\n \/\/ Restore hidden input name after intlTelInput is reinitialized.\r\n $el.siblings('input[type=\"hidden\"]').attr('name', 'wpforms[fields][' + options.hiddenInput + ']');\r\n });\r\n });\r\n <\/script>\r\n \r\n <?php\r\n}\r\n \r\nadd_action('wpforms_wp_footer_end', 'wpf_dev_smart_phone_field_restrict_countries', 30); ","note":"","categories":["wpforms"],"code_type":"php","needs_auth":false,"tags":["wpforms"],"max_version":""},{"library_id":32582,"title":"How to Restrict Numbers in a Single Line Text Form Field","code":"\/**\r\n * Disallow numbers in a single-line text field\r\n *\r\n * @link https:\/\/wpforms.com\/developers\/how-to-restrict-numbers-in-a-single-line-text-form-field\/\r\n *\/\r\n \r\nfunction wpf_dev_disallow_numbers_text_field( $fields, $entry, $form_data ) {\r\n \r\n \/\/ Optional, you can limit to specific forms. Below, we restrict output to\r\n \/\/ form ID #1000.\r\n if ( absint( $form_data[ 'id' ] ) !== 1000 ) {\r\n return $fields;\r\n }\r\n \r\n \/\/ get value of the specific field ID and set it to a variable\r\n \/\/ field ID #25\r\n $mystring = $fields[25][ 'value' ];\r\n \r\n if (!preg_match ('\/^([a-zA-Z]+)$\/', $mystring)) \r\n {\r\n \/\/ Check the field ID 25 and show error message at the top of form and under the specific field\r\n wpforms()->process->errors[ $form_data[ 'id' ] ] [ '25' ] = esc_html__( 'The username can only contain letters.', 'plugin-domain' );\r\n }\r\n \r\n}\r\n \r\nadd_action( 'wpforms_process', 'wpf_dev_disallow_numbers_text_field', 10, 3 );","note":"","categories":["wpforms"],"code_type":"php","needs_auth":false,"tags":["wpforms"],"max_version":""},{"library_id":35399,"title":"How to Set the Language for Google reCAPTCHA","code":"\/**\r\n * Set the language for Google reCAPTCHA.\r\n *\r\n * @link https:\/\/wpforms.com\/developers\/how-to-set-the-language-for-google-recaptcha\/\r\n *\/\r\n\r\nfunction wpf_dev_recaptcha_language( $url ) {\r\n\r\n \/\/ Set the language code to FR (French)\r\n\treturn esc_url_raw( add_query_arg( array( 'hl' => 'fr '), $url ) );\r\n}\r\n\r\nadd_filter( 'wpforms_frontend_recaptcha_url', 'wpf_dev_recaptcha_language', 10, 1);","note":"","categories":["wpforms"],"code_type":"php","needs_auth":false,"tags":["wpforms"],"max_version":""},{"library_id":33061,"title":"How to Use Conditional Logic With a Date Picker","code":"\/**\r\n * Use conditional logic with a date field to show or hide another form field\r\n *\r\n * @link https:\/\/wpforms.com\/developers\/how-to-use-conditional-logic-with-a-date-picker\/\r\n *\/\r\n \r\nadd_action( 'wp_head', function () { ?>\r\n \r\n <style>\r\n \r\n \/* CSS hide this field on page load *\/\r\n #wpforms-form-2575 .age-restriction {\r\n display:none;\r\n }\r\n \r\n \/* CSS show this field if date conditional logic is true *\/\r\n #wpforms-form-2575 .age-restriction.show-field {\r\n display:block;\r\n }\r\n \r\n <\/style>\r\n \r\n<?php } );\r\n \r\n \r\n\/\/ Conditional logic for a field\r\nfunction wpf_dev_age_restriction_check() {\r\n ?>\r\n <script>\r\n jQuery(function($) {\r\n \r\n \/\/ Only fire this script when the field ID 22 for form ID 2575 is changed\r\n document.querySelector( \"#wpforms-2575-field_22-container\" ).onchange = function() { \r\n \r\n \/\/ Get year selected from Date Of Birth field for \r\n \/\/ form ID 2575 and \r\n \/\/ field ID 22\r\n var oneDate = $( \"input#wpforms-2575-field_22\" ).val();\r\n var date_selected = new Date(oneDate); \r\n var date_selected_formatted = date_selected.toLocaleDateString();\r\n var year_selected = date_selected.getYear();\r\n \r\n \/\/ Get current year\r\n var twoDate = new Date();\r\n var now = twoDate.toLocaleDateString();\r\n var year_now = twoDate.getYear();\r\n \r\n \/\/ Is person 21 years or older? \r\n if ((year_now - year_selected) < 21) {\r\n \r\n \/\/ No, then we will continue to hide the single line text field\r\n $( \".age-restriction\" ).addClass( \"no\" );\r\n } \r\n else {\r\n \/\/ Yes, then we will show the single line text field \r\n $( \".age-restriction\" ).addClass( \"show-field\" );\r\n }\r\n \r\n }\r\n \r\n });\r\n \r\n <\/script>\r\n <?php\r\n}\r\nadd_action( 'wpforms_wp_footer_end', 'wpf_dev_age_restriction_check', 10 );","note":"","categories":["wpforms"],"code_type":"php","needs_auth":false,"tags":[],"max_version":""},{"library_id":19033,"title":"Include Field Descriptions Inside Email Notifications","code":"\/* \r\nInclude field descriptions inside email notifications\r\n\r\nOriginal doc link: https:\/\/wpforms.com\/developers\/how-to-include-field-descriptions-inside-email-notifications\/\r\n\r\nFor support, please visit: https:\/\/www.facebook.com\/groups\/wpformsvip\r\n*\/\r\n\r\nfunction wpf_dev_html_field_value( $field_val, $field, $form_data, $context ) {\r\n \r\n if ( $context !== 'email-html' ) {\r\n return $field_val;\r\n }\r\n \r\n if ( empty( $form_data[ 'fields' ][ $field[ 'id' ] ] ) ) {\r\n return $field_val;\r\n }\r\n \r\n $field_data = $form_data[ 'fields' ][ $field[ 'id' ] ];\r\n \r\n if ( empty( $field_data[ 'description' ] ) ) {\r\n return $field_val;\r\n }\r\n \r\n return $field_val . '<p>' . $field_data[ 'description' ] . '<\/p>';\r\n \r\n}\r\nadd_filter( 'wpforms_html_field_value', 'wpf_dev_html_field_value', 20, 4 );","note":"This snippet will have all field descriptions from all forms included in the email notifications.","categories":["wpforms"],"code_type":"php","needs_auth":false,"tags":[],"max_version":""},{"library_id":23135,"title":"Increase the max file size limit in WordPress","code":"\/* \r\nIncrease WordPress upload size, post size, and max execution time \r\n\r\nOriginal doc link: https:\/\/wpforms.com\/how-to-change-max-file-upload-size-in-wordpress\/\r\n\r\nFor support, please visit: https:\/\/www.facebook.com\/groups\/wpformsvip\r\n*\/\r\n\r\n@ini_set( 'upload_max_size' , '256M' );\r\n@ini_set( 'post_max_size', '256M');\r\n@ini_set( 'max_execution_time', '300' );","note":"Using a small snippet, we're going to increase the upload size, post size, and max...","categories":["wpforms"],"code_type":"php","needs_auth":false,"tags":[],"max_version":""},{"library_id":31674,"title":"Increasing Image Size in Notification Emails","code":"\/**\r\n* How to Increase Image Size in Notification Emails\r\n*\r\n* @link https:\/\/wpforms.com\/developers\/how-to-increase-image-size-in-notification-emails\r\n*\/\r\nfunction wpf_custom_wpforms_email_notification_message_thumbnail($message) {\r\n \/\/ Define the new width and height\r\n $new_width = 'auto';\r\n $new_height = 200;\r\n \r\n \/\/ Use preg_replace to modify the width and height of the image\r\n $pattern = '\/<img([^>]*)width=\"(\\d+)\"([^>]*)height=\"(\\d+)\"([^>]*)>\/';\r\n $replacement = '<img$1width=\"' . $new_width . '\"$3height=\"' . $new_height . '\"$5>';\r\n $message = preg_replace($pattern, $replacement, $message);\r\n \r\n return $message;\r\n}\r\nadd_filter('wpforms_emails_notifications_message', 'wpf_custom_wpforms_email_notification_message_thumbnail');","note":"With this PHP snippet, you can easily adjust the size of these images in larger...","categories":["wpforms"],"code_type":"php","needs_auth":false,"tags":["wpforms"],"max_version":""},{"library_id":30011,"title":"Increment a Count on Each Form Submission","code":"\/**\r\n * Increment total entry number on each submission\r\n *\r\n * @link https:\/\/wpforms.com\/developers\/how-to-increment-a-count-on-each-form-submission\r\n *\/\r\n \r\nfunction wpf_dev_update_total_field( $fields, $entry, $form_data ) {\r\n \r\n\t$my_form_id = 1000; \/\/ Form ID to track\r\n if( $form_data[ 'id' ] != $my_form_id ) {\r\n return $fields;\r\n }\r\n \r\n $my_field_id = 15; \/\/ Hidden field ID to store count\r\n \r\n $min_digits = 6; \/\/Minimum digits in counter\r\n \r\n \/\/ Count the entries and increment the hidden field count by 1 on each submit\r\n $total_entries = wpforms()->entry->get_entries( array( 'form_id' => $my_form_id ), true );\r\n $new_total_entries = $total_entries + 1;\r\n \r\n \/\/ Add leading zeros and update field\r\n $fields[ $my_field_id ][ 'value' ] = zeroise($new_total_entries, $min_digits);\r\n \r\n return $fields;\r\n \r\n}\r\nadd_filter( 'wpforms_process_filter', 'wpf_dev_update_total_field', 10, 3 );","note":"This snippet counts the total entries for a specific form and updates a hidden field...","categories":["wpforms"],"code_type":"php","needs_auth":false,"tags":["wpforms"],"max_version":""},{"library_id":24034,"title":"Limit Post Revisions","code":"define( 'WP_POST_REVISIONS', 4 );","note":"This snippet will limit the post revisions storage memory to 4. To get started, you\u2019ll...","categories":["wpforms"],"code_type":"php","needs_auth":false,"tags":[],"max_version":""},{"library_id":13475,"title":"Limit Range Allowed in Numbers Field","code":"\/**\r\n * Limit number range allowed for a Numbers field\r\n * Apply the class \"wpf-num-limit\" to the field to enable.\r\n *\r\n * @link https:\/\/wpforms.com\/developers\/how-to-limit-range-allowed-in-numbers-field\/\r\n * \r\n * For support, please visit: https:\/\/www.facebook.com\/groups\/wpformsvip\r\n *\/\r\n \r\nfunction wpf_dev_num_limit() {\r\n ?>\r\n <script type=\"text\/javascript\">\r\n jQuery(function(){\r\n \r\n \/\/ Enter 5 minimum (5) and maximum (20) amount for the number field \r\n jQuery( '.wpf-num-limit input' ).attr({ 'min':5, 'max':20 } ); \r\n });\r\n \r\n <\/script>\r\n <?php\r\n}\r\nadd_action( 'wpforms_wp_footer_end', 'wpf_dev_num_limit', 30 );","note":"This snippet will allow you to add a CSS class to any Number field and...","categories":["wpforms"],"code_type":"php","needs_auth":false,"tags":[],"max_version":""},{"library_id":22951,"title":"Limiting Options for the Date \/ Time Field","code":"\/** \r\nDon't allow date to be selected after maxDate \r\n\r\nOriginal doc link: https:\/\/wpforms.com\/developers\/customize-the-date-time-field-date-options\/ \r\n\r\nFor support, please visit: https:\/\/www.facebook.com\/groups\/wpformsvip\r\n*\/\r\n\r\nfunction wpf_dev_limit_date_picker() { \r\n ?> \r\n <script type=\"text\/javascript\"> \r\n\t \r\n\t \/\/ Run this snippet on form ID 323 and field ID 4 \r\n window.wpforms_323_4 = window.wpforms_323_4 || {};\r\n window.wpforms_323_4.datepicker = { \r\n disableMobile: true, \r\n \/\/ Don't allow users to pick past dates \r\n maxDate: new Date(), \r\n } \r\n <\/script> \r\n \r\n <?php \r\n} \r\nadd_action( 'wpforms_wp_footer_end', 'wpf_dev_limit_date_picker', 10 );\r\n","note":"This snippet will disable any future date in your date picker. You'll need to update...","categories":["wpforms"],"code_type":"php","needs_auth":false,"tags":[],"max_version":""},{"library_id":21213,"title":"Loading custom templates","code":"\/**\r\n * Plugin Name: WPForms Custom Templates\r\n * Description: This plugin loads custom form templates.\r\n * Version: 1.0.0\r\n *\/\r\n \r\n\/**\r\n * Load the templates.\r\n *\/\r\nfunction wpf_load_custom_templates() {\r\n \r\n \/\/ Template code here\r\n \r\n}\r\nadd_action( 'wpforms_loaded', 'wpf_load_custom_templates' );","note":"Add the code for your custom template to this snippet to load it in the...","categories":["wpforms"],"code_type":"php","needs_auth":false,"tags":[],"max_version":""},{"library_id":30739,"title":"Localizing Date Picker Strings","code":"\/**\r\n * Load the date picker locale strings.\r\n *\r\n * @link https:\/\/wpforms.com\/developers\/localize-the-date-picker-strings\/\r\n *\/\r\n \r\nfunction wpf_dev_datepicker_locale( $forms ) {\r\n if ( true === wpforms_has_field_type( 'date-time', $forms, true )){\r\n wp_enqueue_script( \r\n 'wpforms-datepicker-locale', \r\n 'https:\/\/npmcdn.com\/flatpickr@4.6.13\/dist\/l10n\/es.js',\r\n array( 'wpforms-flatpickr' ), \r\n null, \r\n true\r\n );\r\n }\r\n \r\n}\r\nadd_action( 'wpforms_frontend_js', 'wpf_dev_datepicker_locale', 10 );\r\n","note":"This snippet is used to modify WPForms' default date picker locale","categories":["wpforms"],"code_type":"php","needs_auth":false,"tags":[],"max_version":""},{"library_id":33506,"title":"Merging Multiple WPForms Field Values into Post Content","code":"\/**\r\n * Merging Multiple WPForms Field Values into Post Content\r\n *\r\n * @link https:\/\/wpforms.com\/developers\/merging-multiple-wpforms-field-values-into-post-content\r\n *\/\r\nfunction wpf_dev_post_submissions_process( $post_id, $fields, $form_data ) {\r\n \/\/ If form ID is 463, run code below\r\n if ( 463 !== absint( $form_data[ 'id' ] ) ) {\r\n return;\r\n }\r\n \r\n\/\/ Get values from fields with IDs 2 and 3\r\n$field_2_value = isset( $fields[2]['value'] ) ? $fields[2]['value'] : '';\r\n$field_3_value = isset( $fields[3]['value'] ) ? $fields[3]['value'] : '';\r\n\r\n\/\/ Update post content with the values from fields 2 and 3\r\n$post_content = $field_2_value . ' ' . $field_3_value;\r\nwp_update_post( array(\r\n 'ID' => $post_id,\r\n 'post_content' => $post_content,\r\n) );\r\n\r\n}\r\nadd_action( 'wpforms_post_submissions_process', 'wpf_dev_post_submissions_process', 10, 3 );","note":"","categories":["wpforms"],"code_type":"php","needs_auth":false,"tags":[],"max_version":""},{"library_id":33511,"title":"Overwriting Entries From Users Who Have Already Submitted a Form","code":"\/*\r\n * Remove all user entries before saving the entry - this is for all forms.\r\n *\r\n * @link https:\/\/wpforms.com\/developers\/how-to-overwrite-entries-from-users-who-have-already-submitted-a-form\/\r\n *\/\r\n \r\nfunction remove_all_before_entry_save( $fields, $entry, $form_id ) {\r\n \r\n \/\/get the current user's user ID\r\n $user_id = get_current_user_id();\r\n \r\n \/\/check if the user is logged in, if not logged in skip this code snippet all together\r\n if ( empty( $user_id ) ) {\r\n return;\r\n }\r\n \r\n \/\/perform a query for any entries submitted on this form by this user ID\r\n $entries = wpforms()->entry->get_entries(\r\n [\r\n 'form_id' => $form_id,\r\n 'user_id' => $user_id,\r\n 'number' => -1,\r\n 'select' => 'entry_ids',\r\n 'cap' => false,\r\n ]\r\n );\r\n \r\n \/\/for any previous entries this user has submitted on this form, remove them and replace them with this entry only \r\n foreach ( $entries as $_entry ) {\r\n wpforms()->entry->delete( $_entry->entry_id, [ 'cap' => false ] );\r\n }\r\n}\r\nadd_action( 'wpforms_process_entry_save', 'remove_all_before_entry_save', 9, 3 );","note":"This snippet will overwrite old entries from a user each time they submit a new...","categories":["wpforms"],"code_type":"php","needs_auth":false,"tags":[],"max_version":""},{"library_id":6173,"title":"Position the Field Description Above the Form Field","code":"\/**\r\n * Move the field description above the form field\r\n *\r\n * @link https:\/\/wpforms.com\/developers\/how-to-position-the-field-description-above-the-form-field\/\r\n * \r\n * For support, please visit: https:\/\/www.facebook.com\/groups\/wpformsvip\r\n *\/\r\n\r\nfunction wpf_dev_field_properties( $properties, $field, $form_data ) {\r\n \r\n \/\/ Only process this snippet on form ID 999999\r\n \/\/ To find your form or field ID, visit https:\/\/wpforms.com\/developers\/how-to-locate-form-id-and-field-id\/\r\n if ( absint( $form_data[ 'id' ] ) !== 999999 ) {\r\n return $properties;\r\n } \r\n \r\n {\r\n \/\/ Position the field description above the form field\r\n $properties[ 'description' ][ 'position' ] = 'before';\r\n }\r\n \r\n return $properties;\r\n}\r\nadd_filter( 'wpforms_field_properties', 'wpf_dev_field_properties', 10, 3 );\r\n","note":"Positions the field description above the form field. Change the 999999 to match your own...","categories":["wpforms"],"code_type":"php","needs_auth":false,"tags":["field-description"],"max_version":""},{"library_id":32158,"title":"Processing Smart Tags in HTML Field","code":"\/**\r\n * Process Smart Tags inside HTML \/ Code Block form fields.\r\n *\r\n * @link https:\/\/wpforms.com\/developers\/how-to-process-smart-tags-in-html-fields\/\r\n *\/\r\n\r\nfunction wpf_dev_html_process_smarttags( $properties, $field, $form_data ) {\r\n\r\n $properties[ 'inputs' ][ 'primary' ][ 'code' ] = apply_filters( 'wpforms_process_smart_tags', $properties[ 'inputs' ][ 'primary' ][ 'code' ], $form_data );\r\n\r\n return $properties;\r\n\r\n}\r\nadd_filter( 'wpforms_field_properties_html', 'wpf_dev_html_process_smarttags', 10, 3 );","note":"This snippet makes WPForms Smart Tags usable in the HTML field","categories":["wpforms"],"code_type":"php","needs_auth":false,"tags":[],"max_version":""},{"library_id":32583,"title":"Real-time validation for restricting numbers from Single Line Text field","code":"\/**\r\n * Dynamically prevent numbers from being entered on single line text fields\r\n *\r\n * @link https:\/\/wpforms.com\/developers\/how-to-restrict-numbers-in-a-single-line-text-form-field\/\r\n *\/\r\n \r\nfunction wpf_dev_restrict_numbers( ) {\r\n?>\r\n <script type=\"text\/javascript\">\r\n (function($) {\r\n var No_Numbers_Custom_Validation = {\r\n init: function() {\r\n $(document).on( 'wpformsReady', No_Numbers_Custom_Validation.customRules);\r\n },\r\n customRules: function() {\r\n if (typeof $.fn.validate !== 'undefined') { \r\n $.validator.addMethod( \"check_for_number\", function(value, element, param) {\r\n var $ele = $(element);\r\n return this.optional(element) || ! \/\\d\/.test(value);\r\n }, $.validator.format( \"This field cannot accept numbers.\" ));\r\n }\r\n if ( $( '.no-numbers input' ).length ) {\r\n $( '.no-numbers input' ).rules( 'add', {\r\n check_for_number: true\r\n }); \r\n }\r\n },\r\n }\r\n No_Numbers_Custom_Validation.init();\r\n })(jQuery);\r\n <\/script>\r\n<?php\r\n}\r\nadd_action( 'wpforms_wp_footer_end', 'wpf_dev_restrict_numbers', 30 );","note":"","categories":["wpforms"],"code_type":"js","needs_auth":false,"tags":["wpforms"],"max_version":""},{"library_id":24033,"title":"Reduce Database Calls","code":"\/* \r\nIncrease WordPress upload size, post size, and max execution time \r\n\r\nOriginal doc link: https:\/\/wpforms.com\/how-to-change-max-file-upload-size-in-wordpress\/\r\n\r\nFor support, please visit: https:\/\/www.facebook.com\/groups\/wpformsvip\r\n*\/\r\n\r\n<html xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\" dir=\"ltr\">\r\n<head profile=\"http:\/\/gmpg.org\/xfn\/11\">\r\n<meta http-equiv=\"Content-Type\" content=\"text\/html; charset=UTF-8\" \/>","note":"You can edit your child theme and replace these calls with more specific information to...","categories":["wpforms"],"code_type":"php","needs_auth":false,"tags":[],"max_version":""},{"library_id":6148,"title":"Remove Confirmation Message Box Styling","code":"\/* \r\nRemove Confirmation Message Box Styling\r\n\r\nOriginal doc link: https:\/\/wpforms.com\/developers\/how-to-remove-confirmation-message-box-styling\/\r\n\r\nFor support, please visit: https:\/\/www.facebook.com\/groups\/wpformsvip\r\n*\/\r\n\r\n.wpforms-confirmation-container-full {\r\n color: inherit !important;\r\n margin: 0 !important;\r\n background: none !important;\r\n border: none !important;\r\n padding: 0 !important;\r\n}","note":"Removes the background color and border from the form confirmation message.","categories":["wpforms"],"code_type":"css","needs_auth":false,"tags":["styling"],"max_version":""},{"library_id":23133,"title":"Remove Line Breaks From CSV Exports","code":"\/* \r\nInclude field descriptions inside email notifications\r\n\r\nOriginal doc link: https:\/\/wpforms.com\/developers\/how-to-include-field-descriptions-inside-email-notifications\/\r\n\r\nFor support, please visit: https:\/\/www.facebook.com\/groups\/wpformsvip\r\n*\/\r\n\r\nfunction wpf_dev_remove_line_breaks_csv( $export_data, $request_data, $entry ) {\r\n \r\n array_walk(\r\n $export_data,\r\n static function( &$row ) {\r\n $row = str_replace( \"\\n\", ' ', $row );\r\n }\r\n );\r\n \r\n return $export_data;\r\n \r\n}\r\nadd_filter( 'wpforms_pro_admin_entries_export_ajax_get_entry_data', 'wpf_dev_remove_line_breaks_csv', 10, 3 );\r\n","note":"This snippet will remove the line breaks from CSV exports.","categories":["wpforms"],"code_type":"php","needs_auth":false,"tags":[],"max_version":""},{"library_id":31682,"title":"Remove Multiple Fields From {all_fields} in Notifications","code":"\/**\r\n * Remove Specific Fields from Notifications\r\n *\r\n * @link https:\/\/wpforms.com\/developers\/how-to-remove-specific-fields-from-notifications\r\n *\/\r\nadd_action('wpforms_loaded', function() {\r\n add_filter('wpforms_entry_email_data', function ($fields, $entry, $form_data) {\r\n \/\/ Bail early if form ID is not equal to 1000\r\n if ((int)$form_data['id'] !== 1000) {\r\n return $fields;\r\n }\r\n \r\n \/\/ Unset fields from notifications with field IDs #3, #4, and #5\r\n $fields_to_unset = [3, 4, 5];\r\n foreach ($fields_to_unset as $field_id) {\r\n if (isset($fields[$field_id])) {\r\n unset($fields[$field_id]);\r\n }\r\n }\r\n \r\n return $fields;\r\n }, 11, 3);\r\n});","note":"This code snippet removes multiple fields from your email notifications while still using the {all_fields}...","categories":["wpforms"],"code_type":"php","needs_auth":false,"tags":["wpforms"],"max_version":""},{"library_id":6184,"title":"Remove the Arrows on the Numbers Field","code":"\/* \r\nRemove the arrows in the Numbers form field\r\n\r\nOriginal doc link: https:\/\/wpforms.com\/developers\/how-to-remove-the-arrows-on-the-numbers-field\/\r\n\r\nFor support, please visit: https:\/\/www.facebook.com\/groups\/wpformsvip\r\n*\/\r\n\r\ninput[type=\"number\"]::-webkit-outer-spin-button, input[type=\"number\"]::-webkit-inner-spin-button {\r\n -webkit-appearance: none !important;\r\n margin: 0 !important;\r\n}\r\n \r\ninput[type=\"number\"] {\r\n -moz-appearance: textfield !important;\r\n}","note":"Removes the arrows inside the Numbers form field.","categories":["wpforms"],"code_type":"css","needs_auth":false,"tags":["numbers-field","styling"],"max_version":""},{"library_id":13525,"title":"Remove the Key Text on Conversational Forms","code":"\/* \r\nRemove the Key Text from Conversational Forms\r\n\r\nOriginal doc link: https:\/\/wpforms.com\/developers\/how-to-change-the-key-text-on-conversational-forms\/\r\n\r\nFor support, please visit: https:\/\/www.facebook.com\/groups\/wpformsvip\r\n*\/\r\n\r\n#wpforms-conversational-form-page div[class^='wpforms-field-'] li:not(.wpforms-image-choices-item) label:before,\r\n#wpforms-conversational-form-page div[class*=' wpforms-field-'] li:not(.wpforms-image-choices-item) label:before,\r\n#wpforms-conversational-form-page div[class^='wpforms-field-'] li:not(.wpforms-image-choices-item):not(.wpforms-selected) label:hover:before,\r\n#wpforms-conversational-form-page div[class*=' wpforms-field-'] li:not(.wpforms-image-choices-item):not(.wpforms-selected) label:hover:before,\r\n#wpforms-conversational-form-page div[class^='wpforms-field-'] li:not(.wpforms-image-choices-item):not(.wpforms-selected) label.wpforms-field-item-hover:before,\r\n#wpforms-conversational-form-page div[class*=' wpforms-field-'] li:not(.wpforms-image-choices-item):not(.wpforms-selected) label.wpforms-field-item-hover:before,\r\n#wpforms-conversational-form-page div[class^='wpforms-field-'] li:not(.wpforms-image-choices-item).wpforms-selected label:before,\r\n#wpforms-conversational-form-page div[class*=' wpforms-field-'] li:not(.wpforms-image-choices-item).wpforms-selected label:before {\r\n content:none;\r\n}\r\n \r\n#wpforms-conversational-form-page div[class^='wpforms-field-'] li:not(.wpforms-image-choices-item) label,\r\n#wpforms-conversational-form-page div[class*=' wpforms-field-'] li:not(.wpforms-image-choices-item) label {\r\n padding: 9px 9px 9px 9px;\r\n}","note":"This CSS will remove the Key Text on all Conversational Forms.","categories":["wpforms"],"code_type":"css","needs_auth":false,"tags":[],"max_version":""},{"library_id":33496,"title":"Restricting Address Autocomplete to a Specific Country","code":"\/**\r\n * Restrict address autocomplete to a specific country\r\n *\r\n * @link https:\/\/wpforms.com\/developers\/how-to-restrict-address-autocomplete-to-a-specific-country\/\r\n *\/\r\n \r\nfunction wpf_dev_geo_autocomplete_default_country( ) {\r\n?>\r\n<script type=\"text\/javascript\">\r\n jQuery(function($){\r\n \r\n var formID = 2757; \/\/ Change form ID\r\n \r\n var addressFieldID = 21; \/\/ Change address field ID \r\n \r\n \/\/ Find field place by country\r\n var stateField = window.WPFormsGeolocationGooglePlacesAPI.findFieldPlaceByPolitical($( `#wpforms-${formID}-field_${addressFieldID}-state` )[0]);\r\n \r\n \/\/ Put a country code here according to this list: https:\/\/en.wikipedia.org\/wiki\/List_of_ISO_3166_country_codes\r\n \r\n \/\/ Set default autocomplete country to Canada\r\n stateField.autocomplete.setComponentRestrictions({\r\n 'country': [ 'ca' ],\r\n }); \r\n });\r\n<\/script>\r\n<?php\r\n}\r\nadd_action( 'wpforms_wp_footer_end', 'wpf_dev_geo_autocomplete_default_country', 30 );","note":"This snippet is used to modify the default behavior of the address autocomplete feature in...","categories":["wpforms"],"code_type":"php","needs_auth":false,"tags":[],"max_version":""},{"library_id":32340,"title":"Sending Form Fields as Smart Tags to Square","code":"\/**\r\n * Send the email address to Square\r\n *\r\n * @link https:\/\/wpforms.com\/developers\/how-to-send-the-email-address-to-square-with-wpfoms\/\r\n *\/\r\n \r\nfunction wpf_dev_process_smart_tags_in_payment_description( $args, $process ) {\r\n \r\n if ( isset( $args[ 'note' ] ) ) {\r\n $note = apply_filters( 'wpforms_process_smart_tags', $args[ 'note' ], $process->form_data, $process->fields, 0 );\r\n \r\n \/\/ The maximum length for the Square notes field is 500 characters.\r\n $args[ 'note' ] = wp_html_excerpt( $note, 500 );\r\n }\r\n \r\n return $args;\r\n \r\n}\r\nadd_filter( 'wpforms_square_process_get_payment_args_single', 'wpf_dev_process_smart_tags_in_payment_description', 10, 2 );","note":"The snippet makes Smart Tags usable with Square payments. It allows you to include form...","categories":["wpforms"],"code_type":"php","needs_auth":false,"tags":[],"max_version":""},{"library_id":32165,"title":"Sending Geolocation Data Through Webhooks","code":"\/**\r\n * Send geolocation through webhooks.\r\n *\r\n * @link https:\/\/wpforms.com\/developers\/how-to-send-geolocation-through-webhooks\r\n *\/\r\n \r\nfunction wpf_dev_geolocation_webhook( $options, $webhook_data, $fields, $form_data, $entry_id ) {\r\n \r\n \/\/ Optional, you can limit to specific forms. Below, we restrict output to\r\n \/\/ form #1899.\r\n if ( absint( $form_data[ 'id' ] ) !== 1899 ) {\r\n return $options;\r\n }\r\n \r\n $body = ! is_array( $options[ 'body' ] ) ? json_decode( $options[ 'body' ], true ) : $options[ 'body' ];\r\n \r\n $location = wpforms()->entry_meta->get_meta(\r\n [\r\n 'entry_id' => $entry_id,\r\n 'type' => 'location',\r\n 'number' => 1,\r\n ]\r\n );\r\n \r\n if ( ! empty( $location[0]->data ) ) {\r\n $body[ 'location' ] = $location[0]->data;\r\n }\r\n \r\n $options[ 'body' ] = wp_json_encode( $body );\r\n \r\n return $options;\r\n \r\n }\r\n \r\nadd_filter( 'wpforms_webhooks_process_delivery_request_options', 'wpf_dev_geolocation_webhook', 10, 5 );","note":"This snippet works with the Geolocation and Webhooks addon. It allows you to send geolocation...","categories":["wpforms"],"code_type":"php","needs_auth":false,"tags":[],"max_version":""},{"library_id":32396,"title":"Sending Multiple File Uploads to Google Drive through Zapier","code":"\/**\r\n * Send multiple files to Google Drive with Zapier addon\r\n *\r\n * @link https:\/\/wpforms.com\/developers\/how-to-send-multiple-files-to-google-drive-with-zapier\/\r\n *\/\r\n \r\nfunction wpf_dev_add_zapier_file_upload_filter($data, $entry_id, $form_data) {\r\n \r\n $fields = wpforms_get_form_fields( $form_data );\r\n foreach ( $fields as $field_id => $field ) {\r\n if ( $field['type'] === 'file-upload' ) {\r\n $data[ 'field'.$field_id ] = explode( \"\\n\", stripslashes( $data[ 'field'.$field_id ] ) );\r\n }\r\n }\r\n \r\n return $data;\r\n}\r\nadd_filter('wpforms_zapier_process_entry_data', 'wpf_dev_add_zapier_file_upload_filter', 10, 3);","note":"This snippet modifies our Zapier integration and allows users to send multple files submitted through...","categories":["wpforms"],"code_type":"php","needs_auth":false,"tags":[],"max_version":""},{"library_id":32174,"title":"Sending Numerical Values Through Webhooks","code":"\/**\r\n * Send the numerical values through webhooks.\r\n *\r\n * @link https:\/\/wpforms.com\/developers\/how-to-send-the-numerical-values-through-webhooks\/\r\n *\/\r\n \r\nfunction wpf_dev_webhooks_numeric_value( $filled_params, $params, $process ) {\r\n \r\n \/\/ Request Body params which values should be numeric.\r\n \/\/ List each variable that you want as a number and not a string here separated by a comma and listed in single quotes\r\n $numeric_values = [ 'experience', 'form_id' ];\r\n \r\n foreach ( $filled_params as $key => $param ) {\r\n if ( is_numeric( $param ) && in_array( $key, $numeric_values, true ) ) {\r\n $filled_params[ $key ] = (int) $param;\r\n }\r\n }\r\n \r\n return $filled_params;\r\n \r\n }\r\n \r\nadd_filter( 'wpforms_webhooks_process_fill_http_body_params_value', 'wpf_dev_webhooks_numeric_value', 10, 3);","note":"This snippet allows you to send numbers through Webhooks as opposed to the default behaviour...","categories":["wpforms"],"code_type":"php","needs_auth":false,"tags":[],"max_version":""},{"library_id":32162,"title":"Set a specific language for Cloudflare Turnstile.","code":"\/**\r\n * Set a specific language for Cloudflare Turnstile.\r\n *\r\n * @link https:\/\/wpforms.com\/developers\/how-to-set-the-language-for-cloudflare-turnstile\r\n *\/\r\nfunction wpf_add_turnstile_language_script() {\r\n if (!wp_script_is('wpforms-recaptcha', 'enqueued')) {\r\n return;\r\n }\r\n\r\n $language_code = 'ar-eg'; \/\/ where 'ar-eg' is for Arabic (Egypt) language\r\n \r\n ?>\r\n <script type=\"text\/javascript\">\r\n document.addEventListener('DOMContentLoaded', function() {\r\n if (typeof turnstile === 'undefined') return;\r\n\r\n \/\/ Override turnstile's render function to set the language\r\n var originalRender = turnstile.render;\r\n turnstile.render = function(container, options) {\r\n options = Object.assign({ language: '<?php echo esc_js($language_code); ?>' }, options || {});\r\n return originalRender(container, options);\r\n };\r\n\r\n \/\/ Reinitialize Turnstile when WPForms reCAPTCHA is loaded\r\n document.addEventListener('wpformsRecaptchaLoaded', function() {\r\n document.querySelectorAll('.wpforms-captcha').forEach(function(el) {\r\n if (el.closest('[class*=\"wpforms-is-turnstile\"]')) {\r\n turnstile.remove(el.getAttribute('data-captcha-id'));\r\n turnstile.render(el, {\r\n sitekey: el.getAttribute('data-sitekey'),\r\n language: '<?php echo esc_js($language_code); ?>'\r\n });\r\n }\r\n });\r\n });\r\n });\r\n <\/script>\r\n <?php\r\n}\r\nadd_action('wpforms_wp_footer_end', 'wpf_add_turnstile_language_script', 100);","note":"","categories":["wpforms"],"code_type":"js","needs_auth":false,"tags":["wpforms"],"max_version":""},{"library_id":6188,"title":"Set Default Date for Date Picker","code":"\/**\r\n * Sets a default date for Date Picker\r\n *\r\n * @link https:\/\/wpforms.com\/developers\/how-to-set-a-default-date-for-your-date-picker-form-field\/\r\n * \r\n * For support, please visit: https:\/\/www.facebook.com\/groups\/wpformsvip\r\n *\/\r\n\r\nfunction wpf_dev_date_picker_default() {\r\n ?>\r\n \r\n <script type=\"text\/javascript\">\r\n \r\n window.wpforms_datepicker = {\r\n \r\n defaultDate: \"today\",\r\n disableMobile: \"true\"\r\n \r\n }\r\n \r\n <\/script>\r\n \r\n <?php\r\n}\r\n \r\nadd_action( 'wpforms_wp_footer_end', 'wpf_dev_date_picker_default', 30 );","note":"Sets a default date for your Date Picker form field.","categories":["wpforms"],"code_type":"php","needs_auth":false,"tags":["date-picker","default-date"],"max_version":""},{"library_id":6174,"title":"Set the Language for Google reCAPTCHA","code":"\/**\r\n * Set the language reCAPTCHA\r\n *\r\n * @link https:\/\/wpforms.com\/developers\/how-to-set-the-language-for-google-recaptcha\/\r\n * \r\n * For support, please visit: https:\/\/www.facebook.com\/groups\/wpformsvip\r\n *\/\r\n \r\nfunction wpf_dev_recaptcha_language( $url ) {\r\n \r\n \/\/ Set the language code to FR (French)\r\n \/\/ To find your language code, please visit https:\/\/developers.google.com\/recaptcha\/docs\/language\r\n return esc_url_raw( add_query_arg( array( 'hl' => 'fr '), $url ) );\r\n}\r\n \r\nadd_filter( 'wpforms_frontend_recaptcha_url', 'wpf_dev_recaptcha_language', 10, 1);\r\n","note":"Changes the language when using reCAPTCHA. You'll just need to update the language code. To...","categories":["wpforms"],"code_type":"php","needs_auth":false,"tags":["language","recaptcha"],"max_version":""},{"library_id":32387,"title":"Setting a Default Featured Image for Post Submissions","code":"\/**\r\n * Assign default featured image\r\n *\r\n * @link https:\/\/wpforms.com\/developers\/how-to-set-a-default-featured-image-for-post-submissions\/\r\n *\/\r\n\r\nfunction wpf_dev_post_submissions_process( $post_id, $fields, $form_data ) {\r\n\r\n \/\/ If form ID is 463, run code below\r\n if ( 463 !== absint( $form_data[ 'id' ] ) ) {\r\n return;\r\n }\r\n\r\n \/\/ Assign image as the default featured image\r\n \/\/ Replace 2812 with the image attachment id\r\n $image_id = absint(2812);\r\n\r\n set_post_thumbnail($post_id,$image_id);\r\n\r\n }\r\n\r\nadd_action( 'wpforms_post_submissions_process', 'wpf_dev_post_submissions_process', 10, 3 );","note":"This snippet is used to assign a default image that'll serve as the featured image...","categories":["wpforms"],"code_type":"php","needs_auth":false,"tags":[],"max_version":""},{"library_id":33516,"title":"Setting the Default Address Scheme to International","code":"\/*\r\n * Change the scheme for the address field \r\n *\r\n * @link https:\/\/wpforms.com\/developers\/how-to-set-the-address-default-scheme-to-international\r\n *\/\r\n \r\nfunction wpf_dev_field_new_default( $field ) {\r\n \r\n \/\/ default scheme set to international\r\n if ($field[ 'type' ] === 'address') {\r\n \r\n $field[ 'format' ] = 'international';\r\n \r\n $field[ 'scheme_selected' ] = 'international';\r\n \r\n $field[ 'scheme' ] = 'international';\r\n \r\n $field[ 'country_hide' ] = 'wpforms-hide';\r\n \r\n }\r\n \r\n \/\/ Return\r\n return $field;\r\n \r\n}\r\n \r\nadd_filter( 'wpforms_field_new_default', 'wpf_dev_field_new_default', 10, 1 );","note":"This snippet is used to update the default behavior of the Address field in WPForms....","categories":["wpforms"],"code_type":"php","needs_auth":false,"tags":[],"max_version":""},{"library_id":13471,"title":"Skip Page Breaks When Using Conditional Logic","code":"\/**\r\n * Skip empty page breaks if the condition is not met\r\n *\r\n * @link https:\/\/wpforms.com\/developers\/how-to-skip-page-breaks-when-using-conditional-logic\/\r\n * \r\n * For support, please visit: https:\/\/www.facebook.com\/groups\/wpformsvip\r\n *\/\r\n \r\nfunction wpf_dev_skip_empty_pages() {\r\n?>\r\n \r\n<script type=\"text\/javascript\">\r\n \r\n jQuery(function($){\r\n \r\n \/\/ Initialize the empty action to track which button was clicked (prev\/next)\r\n var action = \"\";\r\n \r\n \/\/ When next\/prev button is clicked, store the action so we know which direction to skip\r\n $( document ).on( 'click', '.wpforms-page-button', function( event ) {\r\n action = $(this).data( 'action' );\r\n });\r\n \r\n \/\/ Check if the page is empty when the page changes\r\n $( '.wpforms-form' ).each(function() {\r\n $(this).on( 'wpformsBeforePageChange', function(event, pageNum, form ){\r\n \r\n \/\/ setTimeout({}, 0) is used so it fires asynchronously. Without this it was happening too quickly\r\n setTimeout(function(){\r\n \r\n \/\/ Assume all pages are empty so we loop through all fields on the page except for the last field which are the page buttons\r\n var emptyPage = true;\r\n \r\n \/\/ Loop through all fields on the page\r\n form.find( `.wpforms-page-${pageNum} > div:not(:last)` ).each(function(){\r\n \r\n \/\/ Check if current field is visible and doesn't have style=\"display:none;\"\r\n if ($(this).is( \":visible\" )) {\r\n \r\n \/\/ Set emptyPage to false if any field is visible on the page\r\n emptyPage = false;\r\n \r\n \/\/ Allow scrolling for pages with fields\r\n window.wpforms_pageScroll = true;\r\n \r\n \/\/ Stop looping through fields if a field is visible\r\n return false;\r\n }\r\n })\r\n \r\n \/\/ Run the \"click\" action on prev or next button if all fields on the page are hidden.\r\n if (emptyPage) {\r\n \r\n \/\/ Prevent any scrolling animation from happening on empty pages\r\n window.wpforms_pageScroll = false;\r\n \r\n \/\/ Perform the \"click\" on the appropriate button based off the saved action\r\n form.find( `.wpforms-page-${pageNum} .wpforms-page-${action}` ).click();\r\n } \r\n }, 0);\r\n });\r\n });\r\n });\r\n \r\n<\/script>\r\n \r\n<?php\r\n}\r\n \r\nadd_action( 'wpforms_wp_footer_end', 'wpf_dev_skip_empty_pages', 30 );","note":"With this snippet, any WPForms form with Conditional Logic and Page Breaks will be skipped...","categories":["wpforms"],"code_type":"php","needs_auth":false,"tags":[],"max_version":""},{"library_id":32188,"title":"Storing User's Uncached IP Address in Hidden Field","code":"\/**\r\n * Do not store the cached IP address in a hidden field\r\n *\r\n * @link https:\/\/wpforms.com\/developers\/how-to-store-the-non-cached-ip-address-into-a-hidden-field\/\r\n *\/\r\n \r\nfunction wpf_hidden_ip_avoid_cache( $fields, $entry, $form_data ){\r\n \r\n \/\/ Only run on the form with ID 727\r\n if( $form_data[ 'id' ] == 727 ) {\r\n \r\n \/\/Look for the hidden field we want to replace the value of\r\n foreach( $fields as $field_id => $field ){\r\n \r\n \/\/ Look for field ID is 10 - it MUST be a Hidden Field, change this ID to match your field ID\r\n if( '10' == $field[ 'id' ] && 'hidden' == $field[ 'type' ] ){ \r\n \r\n \/\/ Replace that value with the IP WPForms detects\r\n $fields[ $field_id ][ 'value' ] = wpforms_get_ip(); \r\n }\r\n }\r\n }\r\n \r\n return $fields; \r\n}\r\nadd_filter( 'wpforms_process_filter', 'wpf_hidden_ip_avoid_cache', 10, 3 );","note":"This snippet lets you capture and store the user's IP address in the Hidden field....","categories":["wpforms"],"code_type":"php","needs_auth":false,"tags":[],"max_version":""},{"library_id":6183,"title":"Style Placeholder Text","code":"\/* \r\nStyle placeholder text\r\n\r\nOriginal doc link: https:\/\/wpforms.com\/developers\/how-to-remove-confirmation-message-box-styling\/\r\n\r\nFor support, please visit: https:\/\/www.facebook.com\/groups\/wpformsvip\r\n*\/\r\n\r\n.wpforms-container ::-webkit-input-placeholder { \/* Chrome and Safari *\/\r\n color: #aaa !important;\r\n}\r\n \r\n.wpforms-container :-moz-placeholder { \/* Mozilla Firefox 4 to 18 *\/\r\n color: #aaa !important;\r\n opacity: 1 !important;\r\n}\r\n \r\n.wpforms-container ::-moz-placeholder { \/* Mozilla Firefox 19+ *\/\r\n color: #aaa !important;\r\n opacity: 1 !important;\r\n}\r\n \r\n.wpforms-container :-ms-input-placeholder { \/* Internet Explorer 10-11 *\/\r\n color: #aaa !important;\r\n}\r\n \r\n.wpforms-container ::-ms-input-placeholder { \/* Microsoft Edge *\/\r\n color: #aaa !important;\r\n}\r\n \r\n.wpforms-container ::placeholder {\r\n color: #aaa !important;\r\n}","note":"Styles the placeholder text that appears inside form fields. The colors in this CSS are...","categories":["wpforms"],"code_type":"css","needs_auth":false,"tags":["placeholder","styling"],"max_version":""},{"library_id":31681,"title":"To Remove a Single Field From {all_fields}","code":"\/**\r\n * Remove Specific Fields from Notifications\r\n *\r\n * @link https:\/\/wpforms.com\/developers\/how-to-remove-specific-fields-from-notifications\r\n *\/\r\nadd_action('wpforms_loaded', function() {\r\n add_filter('wpforms_entry_email_data', function ($fields, $entry, $form_data) {\r\n \/\/ Bail early if form ID is not equal to 1000\r\n if ((int)$form_data['id'] !== 1000) {\r\n return $fields;\r\n }\r\n \r\n \/\/ Unset field from notifications with field ID #3\r\n if (isset($fields[3])) {\r\n unset($fields[3]);\r\n }\r\n \r\n return $fields;\r\n }, 11, 3);\r\n});","note":"This code snippet removes a single field from your email notifications while still using the...","categories":["wpforms"],"code_type":"php","needs_auth":false,"tags":["wpforms"],"max_version":""},{"library_id":40844,"title":"Translating the Total Field's Order Summary","code":"add_action('wpforms_wp_footer_end', function () {\r\n ?>\r\n <script>\r\n (function($) {\r\n $(document).ready(function() {\r\n\r\n \/\/ Replace the text in the Total field and Order Summary to German\r\n $('th.wpforms-order-summary-item-label').text('<?php echo esc_js( __( 'Artikel', 'wpforms' ) ); ?>');\r\n $('th.wpforms-order-summary-item-quantity').text('<?php echo esc_js( __( 'Menge', 'wpforms' ) ); ?>');\r\n $('th.wpforms-order-summary-item-price').text('<?php echo esc_js( __( 'Gesamt', 'wpforms' ) ); ?>');\r\n $('tr.wpforms-order-summary-preview-total .wpforms-order-summary-item-label').text('<?php echo esc_js( __( 'Gesamt', 'wpforms' ) ); ?>');\r\n $('tr.wpforms-order-summary-placeholder td').text('<?php echo esc_js( __( 'Es wurden keine Produkte ausgew\u00e4hlt.', 'wpforms' ) ); ?>');\r\n });\r\n })(jQuery);\r\n <\/script>\r\n <?php\r\n});","note":"This code targets specific elements inside the Order Summary and updates the labels to the...","categories":["wpforms"],"code_type":"php","needs_auth":false,"tags":["wpforms"],"max_version":""},{"library_id":23129,"title":"Troubleshooting Action Scheduler - access the Scheduled Actions page","code":"\/* \r\nChange the completed scheduled tasks storage to 1 week\r\n\r\nOriginal doc link: https:\/\/wpforms.com\/docs\/how-to-troubleshoot-action-scheduler-issues-in-wpforms\/\r\n\r\nFor support, please visit: https:\/\/www.facebook.com\/groups\/wpformsvip\r\n*\/\r\n\r\nadd_filter( 'wpforms_tasks_admin_hide_as_menu', '__return_false' );","note":"Some plugins that install the Action Scheduler library (such as the Action Scheduler plugin itself)...","categories":["wpforms"],"code_type":"php","needs_auth":false,"tags":[],"max_version":""},{"library_id":30741,"title":"Using Conditional Logic to Change Date Picker Locale","code":"\/**\r\n * Conditionally apply the date picker locale strings, depending on what the \r\n * current locale is as defined by WPML.\r\n *\r\n * @link https:\/\/wpforms.com\/developers\/localize-the-date-picker-strings\/\r\n *\/\r\n \r\nfunction wpf_dev_datepicker_apply_locale() {\r\n \r\n if ( defined( 'ICL_LANGUAGE_CODE' ) && 'es' == ICL_LANGUAGE_CODE ) {\r\n ?>\r\n \r\n <script type=\"text\/javascript\">\r\n \r\n jQuery( document ).ready( function() {\r\n \r\n jQuery( '.wpforms-datepicker-wrap' ).each( function() {\r\n var calendar = this._flatpickr;\r\n \r\n if ( 'object' === typeof calendar ) {\r\n calendar.set( 'locale', 'es' );\r\n }\r\n \r\n } );\r\n \r\n } );\r\n \r\n <\/script>\r\n \r\n <?php\r\n }\r\n \r\n}\r\n \r\nadd_action( 'wpforms_wp_footer_end', 'wpf_dev_datepicker_apply_locale', 10 );","note":"This snippet works with the WPML plugin and only apply date picker locale changes when...","categories":["wpforms"],"code_type":"php","needs_auth":false,"tags":[],"max_version":""},{"library_id":30740,"title":"Using Date Picker Localization","code":"\/**\r\n * Apply the date picker locale strings.\r\n *\r\n * @link https:\/\/wpforms.com\/developers\/localize-the-date-picker-strings\/\r\n *\/\r\n \r\nfunction wpf_dev_datepicker_apply_locale() {\r\n ?>\r\n \r\n <script type=\"text\/javascript\">\r\n jQuery( document ).ready( function() {\r\n \r\n jQuery( '.wpforms-datepicker-wrap' ).each( function() {\r\n var calendar = this._flatpickr;\r\n \r\n if ( 'object' === typeof calendar ) {\r\n calendar.set( 'locale', 'es' );\r\n }\r\n \r\n } );\r\n \r\n } );\r\n \r\n <\/script>\r\n \r\n <?php\r\n}\r\n \r\nadd_action( 'wpforms_wp_footer_end', 'wpf_dev_datepicker_apply_locale', 10 );","note":"This snippet is used to apply the changes that instruct WPForms to update the date...","categories":["wpforms"],"code_type":"php","needs_auth":false,"tags":[],"max_version":""},{"library_id":32156,"title":"Using Smart Tags in Your WordPress Rewrite Rules","code":"\/**\r\n * Using Smart Tags in WordPress rewrite rules\r\n *\r\n * @link https:\/\/wpforms.com\/developers\/how-to-use-smart-tags-in-your-wordpress-rewrite-rules\/\r\n *\/\r\n \r\n\/\/ Register custom query var\r\nfunction register_query_var( $wp ) {\r\n parse_str( $wp->matched_query, $url );\r\n \r\n if ( ! isset( $url[ 'email_address' ] ) ) {\r\n return;\r\n }\r\n \r\n $wp->set_query_var( 'email_address', $url[ 'email_address' ] );\r\n}\r\n \r\nadd_filter( 'parse_request', 'register_query_var', 9, 1 );\r\n \r\n\/\/ Replace query var in WPForms smat tags\r\nfunction my_process_smart_tags( $content ) {\r\n \r\n \/\/ Query string var smart tags.\r\n preg_match_all( \"\/\\{query_var key=\\\"(.+?)\\\"\\}\/\", $content, $query_vars );\r\n \r\n if ( ! empty( $query_vars[1] ) ) {\r\n foreach ( $query_vars[1] as $key => $query_var ) {\r\n $value = get_query_var( $query_var ); \/\/ phpcs:ignore\r\n $content = str_replace( $query_vars[0][ $key ], strip_shortcodes( $value ), $content );\r\n }\r\n \r\n }\r\n \r\n return $content;\r\n \r\n}\r\nadd_filter( 'wpforms_process_smart_tags', 'my_process_smart_tags', 9, 1 );","note":"This code snippet converts messy query string URLs into clean, user-friendly URLs while preserving functionality","categories":["wpforms"],"code_type":"php","needs_auth":false,"tags":["wpforms"],"max_version":""},{"library_id":22958,"title":"Using the \u201cInclude Form Styling\u201d Setting","code":"\/* \r\nWhen using Base styling and multi-column, use this CSS to correct the column layout.\r\n\r\nOriginal doc link: https:\/\/wpforms.com\/docs\/how-to-choose-an-include-form-styling-setting\/\r\n\r\nFor support, please visit: https:\/\/www.facebook.com\/groups\/wpformsvip\r\n*\/\r\n\r\n.wpforms-field {\r\n clear: both !important;\r\n}","note":"With the Base styling only setting in place, multi-column layouts will generally not function properly....","categories":["wpforms"],"code_type":"css","needs_auth":false,"tags":[],"max_version":""},{"library_id":23031,"title":"WPForms Enable Modern Markup Settings","code":"\/* \r\nAdding a background image to your forms.\r\n\r\nOriginal doc link: https:\/\/wpforms.com\/docs\/how-to-add-a-background-image-in-wpforms\/\r\n\r\nFor support, please visit: https:\/\/www.facebook.com\/groups\/wpformsvip\r\n*\/\r\n\r\nadd_filter( 'wpforms_admin_settings_modern_markup_register_field_is_hidden', '__return_false' );","note":"By adding this snippet, you will be able to turn the Modern Markup settings on...","categories":["wpforms"],"code_type":"php","needs_auth":false,"tags":[],"max_version":""},{"library_id":22947,"title":"WPForms Login Page Redirect","code":"\/* \r\nModify the login URL to redirect to a custom login page.\r\n\r\nOriginal doc link: https:\/\/wpforms.com\/how-to-create-a-custom-login-form-for-improved-site-branding\/\r\n\r\nFor support, please visit: https:\/\/www.facebook.com\/groups\/wpformsvip\r\n*\/\r\n\r\nfunction sulliesflowers_custom_login_url( $login_url, $redirect, $force_reauth ) {\r\n \/\/ Change here your login page url\r\n $login_url = 'https:\/\/sulliesflowers.com\/login\/';\r\n \r\n if ( ! empty( $redirect ) ) {\r\n $login_url = add_query_arg( 'redirect_to', urlencode( $redirect ), $login_url );\r\n }\r\n if ( $force_reauth ) {\r\n $login_url = add_query_arg( 'reauth', '1', $login_url );\r\n }\r\n return $login_url;\r\n}\r\nadd_filter( 'login_url', 'sulliesflowers_custom_login_url', 10, 3 );","note":"This snippet will redirect the default WordPress login page to your custom login page. This...","categories":["wpforms"],"code_type":"php","needs_auth":false,"tags":[],"max_version":""}]}
| ver. 1.4 |
Github
|
.
| PHP 8.1.32 | Генераци� �траницы: 0.02 |
proxy
|
phpinfo
|
�а�тройка