Skip to content

Instantly share code, notes, and snippets.

@techjewel
Last active December 19, 2024 14:16
Show Gist options
  • Save techjewel/7adb9583426195ef5a7526268b9f634b to your computer and use it in GitHub Desktop.
Save techjewel/7adb9583426195ef5a7526268b9f634b to your computer and use it in GitHub Desktop.
Custom Fluent Forms Conversational Form Landing Page Slug
<?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
@tomilagom
Copy link

tomilagom commented Dec 19, 2024

is there something similar for non-conversational forms? I'd like all the forms to have the same path slug

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment