This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| /** | |
| * Ninja Forms minlength validation | |
| * @author Ron Rosenthal | |
| */ | |
| add_filter('ninja_forms_submit_data', 'custom_ninja_forms_minlength_validation'); | |
| function custom_ninja_forms_minlength_validation($form_data) { | |
| // Specify the field ID and minimum length |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| /** | |
| * Enforce strong passwords for Ninja Forms user registration and profile update actions. | |
| * @description Enforce strong password for Ninja Forms User Management (register/update) — WordPress snippet that validates passwords (8+ chars, uppercase, lowercase, number, special) for Ninja Forms register-user and update-profile actions. Paste into theme functions.php or use a code snippets plugin. | |
| * | |
| * @author Faisal Ahammad <[email protected]> | |
| */ | |
| add_filter('ninja_forms_submit_data', function ($form_data) { | |
| if (!function_exists('Ninja_Forms')) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * Open Ninja Forms redirect URL in a new browser tab after form submission. | |
| * @author Faisal Ahammad <[email protected]> | |
| */ | |
| jQuery(document).ready(function($) { | |
| if (typeof nfRadio !== 'undefined') { | |
| nfRadio.channel('forms').on('submit:response', function(response, textStatus, jqXHR, formId) { | |
| if (response && response.data && response.data.actions && response.data.actions.redirect && response.data.actions.redirect !== '') { | |
| var redirectUrl = response.data.actions.redirect; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * Ninja Forms Phone Starting Digits Blocker | |
| * @author Faisal Ahammad <[email protected]) | |
| */ | |
| jQuery(document).ready(function($) { | |
| // Configuration: Add numbers you want to block from starting the phone number | |
| const BLOCKED_STARTING_NUMBERS = ['0', '1', '88']; | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| jQuery(document).ready(function($) { | |
| function fixMultiSelect() { | |
| $('select[multiple].ninja-forms-field:not([data-fixed])').each(function() { | |
| $(this).attr('data-fixed', 'true') | |
| .on('mousedown', function(e) { | |
| e.preventDefault(); | |
| if (e.target.tagName === 'OPTION') { | |
| var $opt = $(e.target); | |
| $opt.prop('selected', !$opt.prop('selected')); | |
| $(this).trigger('change').trigger('input'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| // Customize the "Max x files are allowed" message in Ninja Forms File Uploads | |
| add_filter( 'ninja_forms_uploads_js_strings', 'custom_ninja_forms_uploads_js_strings' ); | |
| function custom_ninja_forms_uploads_js_strings( $strings ) { | |
| // Change default message to German: "Max %n Dateien sind erlaubt" | |
| $strings['file_limit'] = __( 'Max %n Dateien sind erlaubt', 'ninja-forms-uploads' ); | |
| return $strings; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| /** | |
| * Fix Google reCaptcha v3 loading issue in Ninja Forms with Elementor Pro. | |
| * | |
| * @author Faisal Ahammad <[email protected]> | |
| */ | |
| add_filter('ninja_forms_pre_enqueue_recaptcha_v3_js', 'nfele_enqueue_recaptcha_v3_js'); | |
| function nfele_enqueue_recaptcha_v3_js() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * Set default hour to 09:00 for date/time fields in Ninja Forms | |
| * | |
| * @author Faisal Ahammad <[email protected]> | |
| * | |
| * First add the "setdefaulttime" CSS class in the Date/Time → Display → Container to make this code work. | |
| */ | |
| jQuery(document).ready(function($) { | |
| function checkAndSetHour() { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| /** | |
| * Gravity Forms Advanced Post Creation Auto Resave | |
| * | |
| * This code automatically resaves posts created by the Gravity Forms Advanced Post Creation add-on. | |
| * It ensures that the post is properly saved and updated in the database. | |
| * Visit https://yoursite.com/?force_cron if the code doesn’t run automatically. This URL will force the cron to run. | |
| * | |
| * @author Faisal Ahammad <[email protected]> | |
| */ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| /** | |
| * Gravity Forms: Redirect to Newly Created Post After Submission | |
| * | |
| * @author Faisal Ahammad <[email protected]> | |
| * | |
| * Replace 123 with your actual Gravity Form ID. | |
| */ | |
| add_filter( 'gform_confirmation_123', 'gfapc_redirect_to_created_post', 10, 4 ); |