Skip to content

Instantly share code, notes, and snippets.

@alex-authlab
alex-authlab / fluent form age calculate
Last active January 8, 2023 22:27
Birthday Calculation in Fluent Form
// Age calculator
// 1. First take a Date picker & a text input field
// 2. In the text input element add the class 'age'
// 3. Add a custom class 'date' in the date picker ,then add the following js in your fluent form custom js
jQuery( ".date" ).change(function() {
@alex-authlab
alex-authlab / Fluent Form Unique Email Validation
Last active June 22, 2020 12:05
Prevent submission with duplicate email
/*
* Unique email vaildation
*/
add_action('fluentform_before_insert_submission', function ( $insertData, $data, $formId ) {
if($formId->id != 100) { // You can pass your form id here
return;
}
@alex-authlab
alex-authlab / fluent-form-time-difference.js
Last active June 25, 2020 09:56
Fluent Form Time difference
// 1. Add input text elemet to show the difference
// 2. add 'time-1' & 'time-2' class to the to time input field
// 3. paste the following code in fluent form custom JS
// time format HH:MM
var show_input_selector = '.hour';
var time1 = jQuery('.time-1');
var time2 = jQuery('.time-2');
const convertTime12to24 = (time12h) => {
@alex-authlab
alex-authlab / fluenform_rendering_field_data_input_text.php
Created July 9, 2020 08:51
Fluent Form field data input filter
add_filter( 'fluenform_rendering_field_data_input_text', function($data,$form){
$custom = ['value'=>'Hello','readonly'=>'true'];
$data['attributes'] =array_merge($data['attributes'] ,$custom);
return $data;
},10,2 );
@alex-authlab
alex-authlab / fluent-form-email-filter.php
Created July 9, 2020 09:35
email filter for fluent form
//app\Services\FormBuilder\Notifications\EmailNotification.php
$emailBody = apply_filters('fluentform_email_body', $emailBody, $notification, $submittedData, $form);
$subject = apply_filters('fluentform_email_subject', $notification['subject'], $notification, $submittedData, $form);
$emailTo = apply_filters('fluentform_email_to', $notification['sendTo']['email'], $notification, $submittedData, $form);
return wp_mail(
$emailTo,
$subject,
$emailBody,
$headers,
<?php
add_filter('fluenform_rendering_field_data_select', function ($data, $form) {
if ($form->id != 91) {
return $data;
}
// do the dynamic part if and only the name attriibute is 'dynamic_dropdown'
// Please use the corresponding field name for your case.
if (\FluentForm\Framework\Helpers\ArrayHelper::get($data, 'attributes.name') != 'dynamic_dropdown') {
return $data;
@alex-authlab
alex-authlab / wp-pay-form-hooks.php
Created August 18, 2020 08:08
WP Pay Form Important Hooks
/* PAYMENT */
// Executes when payment is failed
do_action('wppayform/form_payment_failed', $submission, $transaction, $form, $charge, $type);
// Executes when stripe payment is failed
do_action('wppayform/form_payment_stripe_failed', $submission, $transaction, $form, $charge, $type);
// Executes when paypal payment is processing
@alex-authlab
alex-authlab / fluent-form-entry-delete-bulk.php
Last active August 29, 2023 18:03
Fluent Form Entry Delete Bulk
/*
* insert in function.php & remove the code after deleting entries
*/
add_action( 'plugins_loaded', function(){
$formId= 8; // add your form ID
$startId = 20; // Entry Delete start from this ID
$endId = 21; // Entry Delete end with this ID
delete_entry($formId,$startId,$endId);
} );
function delete_entry($formId,$start,$end) {
@alex-authlab
alex-authlab / ff-custom-redirect-filter.php
Last active November 5, 2022 21:08
Fluent Form custom redirect filter
add_filter('fluentform_submission_confirmation', function($returnData, $form, $confirmation )
{
if($form->id != 11){
return;
}
$returnData['redirectUrl'] = 'http://google.com';
$returnData['message'] = "Redirecting";
@alex-authlab
alex-authlab / ff-redirect-using-before-confirmation-hook.php
Last active September 10, 2020 06:14
Fluent Form Dynamic Redirect
add_action('fluenform_before_submission_confirmation', function($entryId, $formData, $form)
{
if($form->id != 11){ // change form ID
return;
}
$email = $formData['email']; // fetch all your data , appened to the URL using & sign
wp_send_json_success([
'result' => [
'redirectUrl' => 'https://google.com/?email='.$email,