Skip to content

Instantly share code, notes, and snippets.

Avatar
🎯
Focusing

Shahjahan Jewel techjewel

🎯
Focusing
View GitHub Profile
@techjewel
techjewel / fluentform-submission-success.js
Last active Sep 15, 2022
Form submission success JS Event in Fluent Forms
View fluentform-submission-success.js
// Event on form submission success
// You can paste this script to Form's custom JS Box
$form.on('fluentform_submission_success', function() {
// You can run your own JS and will be run on successful form submission
});
@techjewel
techjewel / Convert Numbers to Words - Bangladesh.php
Last active Aug 11, 2022
Convert Numbers to Words - for Bangladeshi counting system
View Convert Numbers to Words - Bangladesh.php
<?php
/**
* Function: convert_number
*
* Description:
* Converts a given integer (in range [0..1T-1], inclusive) into
* alphabetical format ("one", "two", etc.)
*
* @int
*
@techjewel
techjewel / event-for-all-forms.js
Created Aug 6, 2020
Track Google Analytics event for all fluent forms in your site
View event-for-all-forms.js
(function($){
if(typeof gtag != 'function') {
return;
}
var fluentForms = $('form.frm-fluent-form');
fluentForms.each(function() {
var $form = $(this);
var formId = $form.attr('data-form_id');
gtag('event', 'ViewForm', {
View tableFilter.php
<?php
/*
* Say you have table which table id is 101 and you want to filter some data
* Please disable caching for this table and load using ajax renderer
*/
add_filter('ninja_tables_get_public_data', function ($data, $tableId) {
if($tableId != 101) {
return $data; // Return if this is not our target table
}
View new_form_submission_smartcode.php
<?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';
@techjewel
techjewel / fluent-forms-title-to-form-html.php
Last active Mar 22, 2022
Add name Attributes to Fluent Forms HTML attributes
View fluent-forms-title-to-form-html.php
<?php
/*
* Add Title Attributes to Fluent Forms
*/
add_filter('fluent_form_html_attributes', function ($atts, $form) {
$atts['name'] = esc_attr($form->title);
return $atts;
}, 10, 2);
@techjewel
techjewel / fluentform-checkbox-max-restriction.js
Last active Feb 15, 2022
prevent users to check max 3/x items from a checkbox group - Fluent Forms
View fluentform-checkbox-max-restriction.js
/**
* 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
*
*/
@techjewel
techjewel / fluent-form-landing-slug.php
Last active Jan 16, 2022
Custom Fluent Forms Conversational Form Landing Page Slug
View fluent-form-landing-slug.php
<?php
/*
* Internal Function for Fluent Forms Custom Slug
* Do not EDIT this function
*/
function customFfLandingPageSlug($slug)
{
add_action('init', function () use ($slug) {
add_rewrite_endpoint($slug, EP_ALL);
@techjewel
techjewel / fluent_form_user_role_change.php
Created Jan 4, 2022
Change User Role on Fluent Forms Submission
View fluent_form_user_role_change.php
<?php
add_action('fluentform_submission_inserted', function ($insertId, $formData, $form) {
if($form->id != 23) { // 23 is your target form id
return;
}
$userId = get_current_user_id();
if(!$userId) {
return;
@techjewel
techjewel / Wordpress Sortcode use in PHP template
Last active Dec 16, 2021
Use sortcode in wordpress template file
View Wordpress Sortcode use in PHP template
<?php echo do_shortcode("[shortcode]");