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 / 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 / Tax_subtract_pay_form
Created March 6, 2021 07:05
Subtracting Tax Calculated Amount instead of adding it in WP Pay Forms
let user_input = $form.find("input[name='custom_payment_input']")[0];
let user_label = $form.find(`label[for='${user_input.id}']`)[0];
// Remove extra stuff in user_label
user_label.textContent = "Inscription à prix libre";
// Create new hidden input
let hidden_input = document.createElement("input");
hidden_input.type = "hidden";
hidden_input.classList.add("wpf_payment_item");
@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 / Check uniqueness of Numeric field in Fluent Forms
Created November 26, 2020 11:17
To check if the user input value in numeric field already exists or not.
use FluentForm\Framework\Helpers\ArrayHelper;
add_filter('fluentform_validate_input_item_input_number', function ($errorMessage, $field, $formData, $fields, $form) {
$fieldName = 'numeric-field';
$target_form_id = 7;
if($target_form_id != $form->id){ return $errorMessage; }
@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 / 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'];
@tahmid-ul
tahmid-ul / FF_Change_user_submited_url_data.php
Last active November 10, 2022 03:04
fluentform_insert_response_data hook is used to change the user submitted data. Here a bunch of urls taken from user input are updated after the submission and a custom query is added at the end automatically. Also for the second part a username is converted to a url in this format - www.example.com/username
// Insert this codes in your functions.php file
add_filter('fluentform_insert_response_data', 'update_url_and_chaturbate_username', 10, 3);
function update_url_and_chaturbate_username($formData, $formid, $inputConfigs)
{
if($formid != 17) {
return $formData;
}