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 / Convert Numbers to Words - Bangladesh.php
Last active April 14, 2023 20:51
Convert Numbers to Words - for Bangladeshi counting system
<?php
/**
* Function: convert_number
*
* Description:
* Converts a given integer (in range [0..1T-1], inclusive) into
* alphabetical format ("one", "two", etc.)
*
* @int
*
<?php
/*
* This snippet is assuming the user already logged in or the provided email address is available in users
* After the form submission the user will be added to the course.
*/
add_action( 'fluentform_submission_inserted', 'ff_register_user_to_learndash_course', 100, 3 );
function ff_register_user_to_learndash_course( $entryId, $formData, $form ) {
// Check if the form is the one we want
<?php
/*
* Code snippet to expose ninja tables data as JSON via URL
* Example URL: https://yourdomain.com/?get_ninja_table_data=1463&key=your_security_key
* In this url 1463 is the table ID that you want to access the data using JSON
* You should change the key 'your_security_key' in the url as well in the code
* to protect the endpoint
*/
add_action('init', function() {
@techjewel
techjewel / fluentform-radio-as-button.css
Created May 25, 2020 23:10
Fluent Forms Radio as Buttons
// You can make the inline radio button look like button switch
// Steps:
// Add container class of the element "ff_button_style"
// Select Layout: Inline Layout
// Lastly add this css to custom css of the form
.ff-el-group.ff_list_inline.ff_button_style .ff-el-form-check {
background: #d2d2d2;
margin: 0 !important;
padding: 0 !important;
@techjewel
techjewel / event-for-all-forms.js
Created August 6, 2020 11:27
Track Google Analytics event for all fluent forms in your site
(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', {
@techjewel
techjewel / fluent-forms_editor_shortcode_extended.php
Created November 12, 2019 05:09
Custom Smart Code in Fluent Forms Example - Author Email
<?php
/*
* Use default value in the editor as
* {embed_post_author_email}
* Then it will show the embeded post's author email
*/
add_filter('fluentform_editor_shortcode_callback_embed_post_author_email', function ($code) {
return get_the_author_meta('user_email');
});
@techjewel
techjewel / atarim-support-for-fluent-crm.php
Created November 17, 2022 14:19
Atarim Support For FluentCRM
<?php
add_filter('fluent_crm_asset_listed_slugs', function ($slugs) {
$slugs[] = '\/atarim-visual-collaboration\/';
return $slugs;
});
// required css
<style>
span.ff_submitting {
display: none;
}
.ff-working span.ff_submitting {
display: block;
}
<?php
function ninjaSanitizeTextOrArray( $array_or_string ) {
if ( is_string( $array_or_string ) ) {
$array_or_string = sanitize_text_field( $array_or_string );
} elseif ( is_array( $array_or_string ) ) {
foreach ( $array_or_string as $key => &$value ) {
if ( is_array( $value ) ) {
$value = ninjaSanitizeTextOrArray( $value );
} else {
@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;
}