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 / 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 / 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');
/*
* 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-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;
//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 / 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;
@nkb-bd
nkb-bd / FluentForm_Checkbox_value_from_url.php
Created October 5, 2021 16:15
Preselect chekbox/radio from get parameter in WP FLuent Forms
<?php
add_filter('fluentform_rendering_field_data_input_checkbox', function ($data, $form) {
{
//change form ID
if ($form->id != 5) {
return $data;
}
//set get param value & match with checkbox value
if (isset($_GET['my_value'])) {
@nkb-bd
nkb-bd / fluentf-form-repeater-validation.php
Last active November 10, 2022 03:51
Fluent Form Repeater Field Unique validation
add_filter('fluentform_validate_input_item_repeater_field', function ($errorMessage, $field, $formData, $fields, $form) {
$name = 'repeater_field';
$data = $formData[$name];
$col_index = 0;
$values= array_column($data,$col_index);
$unique_count = count(array_unique($values));
$count = count($values);
@nkb-bd
nkb-bd / fluent-form-randomize-inputs
Last active September 8, 2021 05:10
Randomize the form Inputs of FluentForms
<?php
// Add this function to function.php and change target form ID
add_filter('fluentform_rendering_form', function ($form) {
// change form ID
$targetFormId = 108;
if ($form->id != $targetFormId) {
return $form;
@nkb-bd
nkb-bd / ff-trigger-inte-feed.php
Created July 26, 2021 08:19
fluent form trigger integration feed
use FluentForm\App\Modules\Form\FormDataParser;
use FluentForm\App\Modules\Form\FormFieldsParser;
if (isset($_GET['test'])) {
function getEntry($id, $form)
{
$submission = wpFluent()->table('fluentform_submissions')->find($id);
$formInputs = FormFieldsParser::getEntryInputs($form, ['admin_label', 'raw']);