Skip to content

Instantly share code, notes, and snippets.

View techjewel's full-sized avatar
🎯
Focusing

Shahjahan Jewel techjewel

🎯
Focusing
View GitHub Profile
@techjewel
techjewel / product_lookup_fluentform.php
Created August 13, 2020 11:10
Get product number and lookup in google sheet and then redirect the user to the target product url.
<?php
/*
* Catch submission the before it's inserting in database
* if you want to log the data in the database use hook: fluenform_before_submission_confirmation
*/
add_action('fluentform_before_insert_submission', function ($insertData, $data, $form) {
if($form->id != 156) { // 156 is our target form id
return;
}
@techjewel
techjewel / gtag-events-for-a-fluentform.js
Created August 6, 2020 11:19
Track Events by Google Analytics for a form in Fluent Forms
gtag('event', 'ViewForm', {
'event_category': 'FluentForms',
'event_label': 'View Form',
'form_id': formId
});
$form.on('fluentform_submission_success', function() {
gtag('event', 'FormSubmission', {
'event_category': 'FluentForms',
'event_label': 'Form Submitted',
@techjewel
techjewel / fluentform-summary-email-hooks.php
Created March 1, 2021 19:39
Fluent Forms Summary Email Text Change
<?php
// changing summary email body text
add_filter('fluentform_email_summary_body_text', function ($text) {
return 'Your own Email Body Text';
});
// changing email footer text
add_filter('fluentform_email_summary_footer_text', function ($text) {
return 'Powered by your agency';
@techjewel
techjewel / fluentform-bulk-option-hook.php
Created August 27, 2021 07:24
Add your own options group for Fluent Forms Editor for Bulk Options
<?php
add_filter('fluentform_editor_vars', function($vars) {
$bulkOptionsJson = $vars['bulk_options_json'];
$arrays = json_decode($bulkOptionsJson, true);
$arrays['New Option Group'] = ['Option 1', 'Option 2'];
$vars['bulk_options_json'] = json_encode($arrays);
return $vars;
});
@techjewel
techjewel / fluentform-extra-form-settings.php
Created September 13, 2021 08:37
Extra Form Settings for Fluent Forms
<?php
// Inject Link Form Settings Menu
add_filter('fluentform_form_settings_menu', function ($items) {
$items['my_menu_slug'] = [
'title' => 'My Menu Title',
'slug' => 'my_settings_slug'
];
return $items;
<?php
function distance($lat1, $lng1, $lat2, $lng2)
{
// convert latitude/longitude degrees for both coordinates
// to radians: radian = degree * π / 180
$lat1 = deg2rad($lat1);
$lng1 = deg2rad($lng1);
$lat2 = deg2rad($lat2);
$lng2 = deg2rad($lng2);
@techjewel
techjewel / FluentFormCustomImporter.php
Created October 23, 2021 12:55
Fluent Form Importer PHP Class
<?php
class FluentFormCustomImporter
{
protected function getDemoForms()
{
return [
'[{"id":"9","title":"Contact Form Demo","status":"published","appearance_settings":null,"form_fields":{"fields":[{"index":0,"element":"input_name","attributes":{"name":"names","data-type":"name-element"},"settings":{"container_class":"","admin_field_label":"Name","conditional_logics":[]},"fields":{"first_name":{"element":"input_text","attributes":{"type":"text","name":"first_name","value":"","id":"","class":"","placeholder":"First Name"},"settings":{"container_class":"","label":"First Name","help_message":"","visible":true,"validation_rules":{"required":{"value":false,"message":"This field is required"}},"conditional_logics":[]},"editor_options":{"template":"inputText"}},"middle_name":{"element":"input_text","attributes":{"type":"text","name":"middle_name","value":"","id":"","class":"","placeholder":"","required":false},"settings":{"container_class":"","label":"Middle Name","help_message":"","error
<?php
/*
* Fluent Forms Extra Smartcodes on form integration feeds
* This code will add a new item on the smartcode dropdown.
* if you don't want to show the smartcode then you may skip this.
*/
add_filter('fluentform_form_settings_smartcodes', function ($groups) {
$groups[0]['shortcodes']['{my_custom_smartcode}'] = 'Custom All Data';
<?php
add_action('fluentcrm_confirmation_head', function ($subscriber) {
$redirectUrl = 'https://google.com'; // Change this url;
echo '<meta http-equiv="refresh" content="0; URL='.$redirectUrl.'" />';
});
<?php
/*
* Function to push a task for background processing
* @param: string $callbackName - Your classback acction name
* @param: mixed $payload - Your payload data that you will get when procssing on callback
*/
function my_custom_queue_on_background($callbackName, $payload)
{