Skip to content

Instantly share code, notes, and snippets.

View nkb-bd's full-sized avatar

Lukman Nakib nkb-bd

View GitHub Profile
@nkb-bd
nkb-bd / fluent-form-dynamic-user-role.php
Created October 21, 2021 15:18
Set dynamic user role for WP Fluent Forms
add_filter('fluentform_user_registration_feed',function($feed, $entry, $form){
if($form->id != 1){
return;
}
//get role value
$response = json_decode($entry->response,true);
$roleInputName = 'input_radio';
$role = $response[$roleInputName];
//set role
$feed['processedValues']['userRole'] = $role;
//paste this in the custom JS section of fluentform
$form.on('submit',function(){
var text = 'Hello Alex';
var phone = '8801715928113';
window.open(`http://api.whatsapp.com/send?phone=${phone}&text=${text}`, '_blank');
});
@nkb-bd
nkb-bd / fluentform-quiz-result-filter.php
Created April 25, 2022 09:53
WP Fluentform quiz result filter for custom response
add_filter('fluentform_quiz_score_value', function ($result, $formId, $scoreType, $quizResults){
$targetId = 154; // change your form ID
if($formId != $targetId){
return $result;
}
if($scoreType == 'percent'){
$score = 0;
$totalPoints = 0;
/*
* Input Default Values form url array values
* {thrivecart.customer.email}
*/
add_filter('fluentform_editor_shortcode_callback_group_thrivecart', function ($handler, $form, $handlerArray) {
$handler = \FluentForm\App\Services\FormBuilder\EditorShortcodeParser::parseValue($handler);
$handlerKey = array_pop($handler);
if (!$handlerKey) {
return '';
}
@nkb-bd
nkb-bd / fluentform-style-off-filter.php
Created January 16, 2023 05:38
WP Fluent Form Plugin Default Style Off
//turn off form style
add_action( 'wp_enqueue_scripts', function () {
wp_deregister_style( 'fluentform-public-default' );
}, 99 );
//turn off button style
add_filter('fluentform_submit_button_force_no_style','__return_true');
@nkb-bd
nkb-bd / wp-config.php
Last active October 22, 2024 03:10
Valet Share for WordPress using ngrok
//Share a public live url of you local site
// First setup ngork you will need an account
//add these to wp-config.php
$_SERVER['HTTPS'] = 'on';
define('WP_SITEURL', 'https://' . $_SERVER['HTTP_X_ORIGINAL_HOST']);
define('WP_HOME', 'https://' . $_SERVER['HTTP_X_ORIGINAL_HOST']);
$_SERVER['HTTP_HOST'] = $_SERVER["HTTP_X_ORIGINAL_HOST"]; // Valet share hack
@nkb-bd
nkb-bd / random.php
Created March 6, 2023 06:45
Random WordPress Filter & Hooks
//adding nonce in extra js inline script
add_filter('script_loader_tag', function ($tag, $handle) {
if ('script-handler' === $handle) {
$nonce = wp_create_nonce();
$tag = str_replace('<script ', "<script nonce='$nonce' ", $tag);
}
return $tag;
}, 10, 2);
@nkb-bd
nkb-bd / gist:b0968c015b34287e7687257820154637
Created March 14, 2023 12:21
Single Form Admin Access for Fluent Form
//First Set all permission for the user from the settings
add_action('init',function (){
$userId = 18; //Enter User ID (except admin)
$formId = 11; //Fluent Form ID
customPermissionRule($userId,$formId);
});
function customPermissionRule($userId,$formId){
if($userId != get_current_user_id()){
return;
@nkb-bd
nkb-bd / file-upload-issue.php
Created March 17, 2023 10:38
ff file upload issue fix
// Please remove and add the file input again to work properly.
add_filter('fluentform_file_type_options', function ($options) {
$options[2]['value'] = 'avi|divx|flv|mov|ogv|mkv|mp4|m4v|divx|mpg|mpeg|mpe|qt';
return $options;
});
<!--
hero: https://bulma.io/documentation/layout/hero/
section: https://bulma.io/documentation/layout/section/
image: https://bulma.io/documentation/elements/image/
columns: https://bulma.io/documentation/columns/basics/
media: https://bulma.io/documentation/layout/media-object/
icon: https://bulma.io/documentation/elements/icon/
breadcrumb: https://bulma.io/documentation/components/breadcrumb/
level: https://bulma.io/documentation/layout/level/
-->