In this short tutorial, I am going to show you how to get the slug from a url.
1. Create the fields
We need to create two fields:
Text field with name attribute –
Hidden field with the name attribute –
2. Adding the code
We need to then hook into one of the many Fluent Form hooks that exist.
The hook we need is
What we are doing in this hook is getting the input from the user. In this case it’s
plugin_url and then usin g the built-in basename PHP function to extract the trailing name. (Or last part after the
As you can see from the image below, the function pulls the slug from the end of both url’s and saves them in the hidden field we created.
Note: Make sure to replace your form ID