Last active
November 5, 2022 21:10
-
-
Save techjewel/7adb9583426195ef5a7526268b9f634b to your computer and use it in GitHub Desktop.
Custom Fluent Forms Conversational Form Landing Page Slug
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
* Internal Function for Fluent Forms Custom Slug | |
* Do not EDIT this function | |
*/ | |
function customFfLandingPageSlug($slug) | |
{ | |
add_action('init', function () use ($slug) { | |
add_rewrite_endpoint($slug, EP_ALL); | |
}); | |
add_action('wp', function () use ($slug) { | |
global $wp_query; | |
if (isset($wp_query->query_vars[$slug])) { | |
$formString = $wp_query->query_vars[$slug]; | |
if (!$formString) { | |
return; | |
} | |
$array = explode('/', $formString); | |
$formId = $array[0]; | |
if (!$formId || !is_numeric($formId)) { | |
return; | |
} | |
$secretKey = ''; | |
if (count($array) > 1) { | |
$secretKey = $array[1]; | |
} | |
$paramKey = apply_filters('fluentform_conversational_url_slug', 'fluent-form'); | |
$_GET[$paramKey] = $formId; | |
$_REQUEST[$paramKey] = $formId; | |
$_GET['form'] = $secretKey; | |
$_REQUEST['form'] = $secretKey; | |
} | |
}); | |
} | |
/* | |
* Creating custom slug for conversational form landing page | |
* | |
* my-forms-x is your custom slug for the form | |
* if your form id is 123 then the landing page url will be then | |
* https://your-domain.com/my-forms/123 | |
* if you use Security Code on conversational form then the url will be | |
* https://your-domain.com/my-forms/123/SECURITY-CODE | |
* | |
* After paste the code to your theme's functions.php file please re-save the permalink settings | |
*/ | |
customFfLandingPageSlug('my-forms'); // you may change the "my-forms" for your own page slug |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment