Skip to content

Instantly share code, notes, and snippets.

@alex-authlab
alex-authlab / fluent-form-set-radio-value-from-url.php
Last active December 28, 2021 18:11
Fluent Forms Select Radio Field Value from Url
add_filter('fluentform_rendering_field_data_input_radio', function ($data, $form) {
//change form id
if ($form->id != 91) {
return $data;
}
//add your get param key
$key = 'my_get';
if(isset($_GET[$key])){
$data['attributes']['value'] = sanitize_text_field($_GET[$key]);
add_filter('fluentform_file_type_options', function ($types) {
$types[] = [
'label' => __('3d files - DWG, STL, STEP, STP, SKP, MAX, FBX, 3DS, IGES, OBJ', 'fluentform'),
'value' => 'dwg|stp|stl|STEP|skp|max|fbx|3ds|iges|obj',
];
return $types;
});
add_filter('upload_mimes', function ($mime_types) {
$mime_types ['dwg'] = 'image/vnd.dwg';
// booking date check in > check out
// add the two class 'in-date' & 'out-date'
$( document ).ready(function() {
var check_in = flatpickr(".in-date",{dateFormat: "d/m/Y",});
var check_out = flatpickr(".out-date",{dateFormat: "d/m/Y",});
check_in.element.addEventListener("change", function(){
@alex-authlab
alex-authlab / fluentform-radio-opiton-filter.php
Created June 20, 2021 12:12
fluent form input radio filter
add_filter('fluenform_rendering_field_data_input_radio', function ($data, $form) {
if ($form->id != 91) {
return $data;
}
// check if the name attriibute is 'checkbox', make sure it mathc
if (\FluentForm\Framework\Helpers\ArrayHelper::get($data, 'attributes.name') != 'checkbox') {
return $data;
}
@alex-authlab
alex-authlab / fluentform-php-hooks.php
Created June 17, 2021 11:51
FluentForm PHP hooks list
<?php
//form
do_action('fluentform_loaded');
//do_action('fluentform_before_insert_submission', $insertData, $data, $this->form);
do_action('fluentform_before_form_actions_processing', $insertId, $this->formData, $this->form);
//do_action('fluenform_before_submission_confirmation', $insertId, $formData, $form);
//do_action('fluentform_submission_inserted', $insertId, $formData, $form);
//payment
@alex-authlab
alex-authlab / customFormRedirectFF.php
Created April 23, 2021 10:43
redirect by checking zip codes set
add_filter('fluentform_form_submission_confirmation', function($confirmation,$formData,$form){
$targer_form_id = 11;
if($form->id!= $targer_form_id) {
return ;
}
$set_1 = ['ABCD','AAAA'];
$set_2 = ['ABAB','BBBB'];
@alex-authlab
alex-authlab / fluentform-checkbox-max-restriction.js
Created April 2, 2021 04:07 — forked from techjewel/fluentform-checkbox-max-restriction.js
prevent users to check max 3/x items from a checkbox group - Fluent Forms
/**
* Function to prevent users mark more than expected items.
* This code must need to be placed in custom JS of your form
* @param: containerClass String - The contaner class of the target checkbox block.
* You can add a custom container class in the form settings
*
* @param: maxChecked Integer - Max Number of items user can mark
* @return: void
*
*/
add_action('recaptcha_custom_function', 'recaptcha_custom_function_callback', 10, 1 );
function recaptcha_custom_function_callback( $form) {
echo '
<script type="text/javascript">
jQuery( document ).ready(function() {
jQuery(".ff-btn-submit").attr("disabled", "true");
});
function enableBtn(){
jQuery(".ff-btn-submit").removeAttr("disabled");
}
@alex-authlab
alex-authlab / fluent-form-email-attachment-filter.php
Last active March 23, 2021 13:57
WP Fluent Forms Email Attachment Filter
add_filter('fluentform_filter_email_attachments', function($emailAttachments, $notification,$form, $entry){
$target_form_id = 29;
if($form->id != $target_form_id){
return;
}
$media_id = 144;
$emailAttachments[] = get_attached_file($media_id);
//or pass the exact file location like this
@alex-authlab
alex-authlab / flatpicker.js
Created March 9, 2021 04:37
flatpicker set check in date < check out date
// booking date check in > check out
$( document ).ready(function() {
var check_in = flatpickr(".in-date",{dateFormat: "d/m/Y",});
var check_out = flatpickr(".out-date",{dateFormat: "d/m/Y",});
check_in.element.addEventListener("change", function(){
check_out.set( "minDate" , check_in.element.value );
});