Skip to content

Instantly share code, notes, and snippets.

View tahmid-ul's full-sized avatar
🎯
Focusing

Tahmid ul karim tahmid-ul

🎯
Focusing
  • AuthLab
  • Sylhet, Bangladesh
View GitHub Profile
@tahmid-ul
tahmid-ul / FF_Update_Submission_Time
Created October 1, 2020 11:12
Change form submission time from GMT to the set time zone.
add_filter('fluentform_filter_insert_data', 'change_ff_submitted_timezone', 10, 1);
function change_ff_submitted_timezone($response)
{
// Set the timezone that you want to display
$userTimezone = new DateTimeZone('Asia/Dhaka');
$gmtTimezone = new DateTimeZone('GMT');
$myDateTime = new DateTime($response['created_at'], $gmtTimezone);
$offset = $userTimezone->getOffset($myDateTime);
/*
* Add the smartcode to the list
*/
add_filter('fluentform_editor_shortcodes', function ($smartCodes) {
$smartCodes[0]['shortcodes']['{current_time}'] = 'Current Time';
return $smartCodes;
});
/*
* Transform the smartcode
@tahmid-ul
tahmid-ul / ShuffleTableRows
Created February 18, 2021 09:14
Randomize/shuffle table rows
/*Randomize/shuffle the table rows each time after refresh the page*/
(function($){
//Shuffle all rows, while keeping the first column
//Requires: Shuffle
$.fn.shuffleRows = function(){
return this.each(function(){
var main = $(/table/i.test(this.tagName) ? this.tBodies[0] : this);
var firstElem = [], counter=0;
main.children().each(function(){
@tahmid-ul
tahmid-ul / Total Donation Amount and Count
Last active April 8, 2021 08:06
Total Donation Amount and Count
/*
* Total Donation Count
*/
add_filter('fluentform_editor_shortcodes', function ($smartCodes) {
$smartCodes[0]['shortcodes']['{total_donation_count}'] = 'Total Donation Count';
return $smartCodes;
});
add_filter('fluentform_editor_shortcode_callback_total_donation_count', function ($value, $form) {
@tahmid-ul
tahmid-ul / ff_repeater_sum.js
Created April 21, 2021 19:48
Calculates the sum of the numbers entered in each row of repeater field in Fluent forms
(function($) {
let minus;
$('body').on('click','.js-repeat-buttons',function(){
calculate();
})
function calculate(){
let length = $('table.ff_repeater_table > tbody > tr').length
let plocha = 0;
@tahmid-ul
tahmid-ul / Remaining Entries in Fluent Forms using smart shortcodes
Last active May 17, 2021 07:43
Calculate the remaining entries when the max submission limit is set and the value can be displayed in front end.
/* Snippet: A smart shortcodes will be generated that can be added to any field on the form and it will be displayed in front-end */
add_filter('fluentform_editor_shortcodes', function ($smartCodes) {
$smartCodes[0]['shortcodes']['{remaining_entries}'] = 'Remaining Entries';
return $smartCodes;
});
add_filter('fluentform_editor_shortcode_callback_remaining_entries', function ($value, $form) {
$max_entries = $form->settings['restrictions']['limitNumberOfEntries']['numberOfEntries'];
<?php
/*
* If you select plain design on email feed for email. Fluent Forms does not add any additional html templating for email body.
* But your email body still may have HTML from the email body composer and smart codes. You can use this snippet to convert the body in pure-text format
*/
add_filter('fluentform_email_body', function($body, $notification) {
if(isset($notification['asPlainText']) && $notification['asPlainText'] == 'yes') {
return strip_tags($body, '<b><strong>');
@tahmid-ul
tahmid-ul / Number_format_individual_shortcode.php
Last active June 2, 2021 08:18
Fix number format (EU, US) for individual shortcode when used in pdf or email.
<?php
add_filter('fluentform_response_render_input_number', function ($response, $field, $form_id, $isHtml = true) {
if (!$response ) {
return $response;
}
$fieldSettings = \FluentForm\Framework\Helpers\ArrayHelper::get($field, 'raw.settings');
$formatter = \FluentForm\Framework\Helpers\ArrayHelper::get($fieldSettings, 'numeric_formatter');
@tahmid-ul
tahmid-ul / fluent_form_image_choice_style.css
Last active June 11, 2021 06:31
Clickable image for Radio or Checkbox field
/**
* Styles the Radio field as clickable image for Fluent Forms
*
* Use: Paste into Custom CSS Section of your Form
* Add class "fancy-input" to container of all inputs that need the fancy styling
*
* Forked version of Sebastian Berger from inital post Fluent Forms FB Group - https://bit.ly/37BBpet
* FB Post - https://bit.ly/2ZEn2BG
*
* Full Links at bottom
@media (max-width: 1024px) {
table.ff_flexible_table tbody tr {
display: block;
background: #fff;
position: relative;
border-bottom: 1px solid #ced4da;
border-top: 1px solid #ced4da;
border-color: #ced4da;
border-style: solid;
border-width: 2px 1px 4px;