Skip to content

Instantly share code, notes, and snippets.

View aimahdi's full-sized avatar
💭
Working on something bigger

Amimul Ihsan aimahdi

💭
Working on something bigger
View GitHub Profile
add_action( 'woocommerce_review_order_before_submit', 'custom_content_before_order_submit_button' );
function custom_content_before_order_submit_button() {
(new \FluentCampaign\App\Services\Integrations\WooCommerce\WooInit())->addSubscribeBox();
}
add_filter('fluentform/validate_input_item_input_email', function ($default, $field, $formData, $fields, $form) {
// You may change the following 3 lines
$targetFormId = 101; //change the form id with your own.
$errorMessage = 'Looks like email is not correct, please use a valid email'; // You may change/modify the meessage
$apiKey = 'lYlSwj3Uxt5iGecFTHYdqKC4xBQYaClfsss'; //reoon API key, you should use your own api key
if ($form->id != $targetFormId) {
return $default;
}
add_filter('fluentform/response_render_tabular_grid', function ($response, $field, $form_id, $isHtml = false) {
$field['raw']['settings']['grid_columns'] = ['Ashik'=>'Ashik', 'Ruman'=>'Ruman'];
$field['raw']['settings']['grid_rows'] = ['Ibrahim'=>'Ibrahim', 'Nadim'=>'Nadim', 'Tahmid'=>'Tahmid', 'Mahdi'=>'Mahdi'];
return \FluentForm\App\Modules\Form\FormDataParser::formatTabularGridFieldValue($response, $field, $form_id, $isHtml);
}, 9, 4);
add_filter('fluentform/editor_countries', function ($country_names) {
foreach ($country_names as $key => $value) {
if (preg_match("/\([^)]+\)/", $value)) {
$replacedValWithSpaceInBetween = preg_replace("/\s+\([^)]+\)/", "", $value);
$country_names[$replacedValWithSpaceInBetween] = $replacedValWithSpaceInBetween;
} else {
$country_names[$value] = $value;
}
unset($country_names[$key]);
}
@aimahdi
aimahdi / Conversational forms custom js.js
Created September 9, 2023 09:41
Use custom JS on conversational forms
add_action('fluentform/conversational_frame_footer', function() {
printf("<script type='text/javascript' id='%s-js-extra'>\n", esc_attr($handle));
$data = "
let name = document.querySelector(\"[name=\'input_text\']\");
name.value = \"Ibrahim Mahdi\";
console.log(name.value)";
echo "$data\n"; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- $data is hardcoded localized data and escaped before being passed in.
let rangeSliderOne = document.querySelector("#ff_798_rangeslider");
let rangeSliderTwo = document.querySelector("#ff_798_rangeslider_1");
let rangeSliderThree = document.querySelector("#ff_798_rangeslider_2");
let rangeValues = document.querySelectorAll(".ff_range_value");
rangeSliderOne.onchange = function(event){
let commaValue = event.target.value.replace(/\B(?=(\d{3})+(?!\d))/g, ",");
add_filter('fluentform_rendering_field_data_select', function ($data, $form) {
$targetFormID = 15;
//google sheet shared as CSV link
$csvUrl = 'https://docs.google.com/spreadsheets/d/e/2PACX-1vT-mQ_isy2CXOi70SjjbNaCPbmhmshikUS8o3nEthE2N-6NsqdABnW6Crlmb2DegaO6IsM9QcjlWPz4/pub?output=csv';
$columName = 'Processos ativos'; // 'Players' is the column name
$uniqueData = true; // remove duplicate values
if ($form->id != $targetFormID) {
add_filter('fluent_crm/theme_pref', 'changeColorPalette', 10, 1);
function changeColorPalette(){
$color_palette = [
[
"name" => __("MyBlue", "fluent-crm"),
"slug" => "myblue",
"color" => "#336699"
],
add_action('fluentform_before_insert_submission', 'validate_email_reoon', 10, 3);
function validate_email_reoon($insertData, $data, $form)
{
if($form->id != 633) { //change the form id with your form id
return;
}
$apiKey = 'lYlSwj3Uxt5iGecFTHYdqKC4xBQYaClf'; //put your api key here
@aimahdi
aimahdi / ff_unique_dropdown.php
Created October 22, 2022 08:29
make the dropdown field unique
add_filter('fluentform_validate_input_item_select', function ($errorMessage, $field, $formData, $fields, $form) {
$fieldName = 'dropdown'; //name attribute of the dropdown field
$target_form_id = 597; //change the form id
if($target_form_id != $form->id){ return $errorMessage; }
if ($inputValue = \FluentForm\Framework\Helpers\ArrayHelper::get($formData, $fieldName)) {