On one of the sites that I manage, on which I am using Formidable Forms, I received some user feedback regarding the message that is displayed to logged out users when a form’s permissions are set to limit form visibility to logged in users.
By default this message says “You do not have permission to view this form.”
I had modified this to say “Kindly sign in to the site before registering for this event.”
Users quite rightly pointed out that it would be helpful to include a hyperlink to the login form, especially given that we were using Formidable Form actions to email them the direct link to that page.
Of course, the global login message can be modified under Global Settings / Message Defaults; however there are some limitations. While you can add a static hyperlink in the message field, this doesn’t allow you to dynamically redirect the user back to the page where a limited form was embedded after successfully signing in.
After reading up on the Formidable Knowledge Base and the WordPress Developer Reference, I put together a small plugin which allows you to replace the global login message with one that includes a login link which redirects back to the page where the form was embedded.
This works on a page, a post, or even inside the detail page of a Formidable View – for example if there was a list of events embedded on the page
/Events/, Formidable Views generates a virtual page for the details, which might be
/Events/?eventdetail=25; let’s say you wanted to embed a registration form onto this event detail View, you could insert the form there, and if login were required, this plugin would display the login link, and successfully redirect back to that detail View directly. More details can be found at the link below.
Rather than replacing the entire string by hardcoding it inside the plugin, it will search for a word surrounded by asterisks and apply the hyperlink to it, for example:
You do not have permission to view this form – *please sign in* to continue.
You do not have permission to view this form – please sign in to continue.