Skip to content

Instantly share code, notes, and snippets.

Avatar
🎯
Focusing

Shahjahan Jewel techjewel

🎯
Focusing
View GitHub Profile
View dynamic_smartcode_in_fluentforms.php
<?php
/*
* Smartcode callback for smartcode: {sondre_post_selection_meta}
*/
add_filter('fluentform_shortcode_parser_callback_sondre_post_selection_meta', function ($returnValue, $instance) {
$userInputs = $instance::getInputs();
// from $userInputs you can access what user have provided information
// if your post selection input name is cpt_selection then you can access the post id as
$selectedPostId = $userInputs['cpt_selection'];
@techjewel
techjewel / fluentform-summary-email-hooks.php
Created Mar 1, 2021
Fluent Forms Summary Email Text Change
View fluentform-summary-email-hooks.php
<?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';
View addTagToCurrentContact.php
<?php
// add a tag to a current logged in or cookie based contact
// getCurrentContact() method will find the contact from logged in info or from the cookie from email link click
// For more api doc: https://github.com/FluentCRM/fluent-crm/wiki/PHP-API
$contact = FluentCrmApi('contacts')->getCurrentContact();
$tagsToAdd = [1,2];
if($contact) {
View users_rest_secure_wp.php
<?php
/*
* Disable users REST endpoint for public or not author users users
* To access the endpoint the user must need to be contributor
* aka need to have edit_posts permission
*/
add_filter( 'rest_endpoints', function ($endpoints) {
$endpoints_to_remove = array(
'/wp/v2/users'
@techjewel
techjewel / custom_shortcode_in_fluentforms.php
Created Feb 6, 2021
Create a custom shortcode for email / confirmation or other after form submit
View custom_shortcode_in_fluentforms.php
<?php
/*
* Create a custom shortcode for email / confirmation or other after form submit
* Usage: {my_custom_shortcode}
* @param $value string original shortcode string
* @param $parser class \FluentForm\App\Services\FormBuilder\ShortCodeParser
*/
add_filter('fluentform_shortcode_parser_callback_my_custom_shortcode', function ($value, $parser) {
@techjewel
techjewel / product_lookup_fluentform.php
Created Aug 13, 2020
Get product number and lookup in google sheet and then redirect the user to the target product url.
View product_lookup_fluentform.php
<?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;
}
View add-universal-event-tracking-fluent-forms.php
<?php
/*
* Add the folliwing code to your theme's functions.php file.
* This code will only load if a page has fluent forms.
*/
add_action('fluentform_before_form_render', function () {
static $isloaded = false;
if($isloaded) {
@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', {
@techjewel
techjewel / gtag-events-for-a-fluentform.js
Created Aug 6, 2020
Track Events by Google Analytics for a form in Fluent Forms
View gtag-events-for-a-fluentform.js
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',
View fluentform-checkable-button-mobile.css
@media (max-width: 767px) {
.fluentform .ff-el-group.ff_list_buttons .ff-el-form-check span {
width: 100% !important;
border-left: 1px solid #dcdfe6 !important;
border-radius: 0 !important;
}
.fluentform .ff-el-group.ff_list_buttons .ff-el-form-check {
margin-top: -1px !important;
display: block !important;