Limit the validity of activation mail link

By: Athira Divakar | Asked: 05/19/2023
ForumsCategory: General questionsLimit the validity of activation mail link
Athira Divakar asked 2 years ago
Is there a way by which we can limit the validity of the activation mail sent from formidable after registration? If after 24hrs say the user tries to access the email verification link, the link expires by then.
1 Answers
Victor Font answered 2 years ago
I just spent some time looking through the source code for class FrmRegModerationController. This is where Formidable handles the email activation link processing and I have good and bad news for you. And the question you need to answer, is how bad do you want this feature?
Victor Font replied 2 years ago

First, the good news.

It's not a lot of code at just 473 lines. So, it didn't take long for me to find the answer. The first thing I look for, when I have a requirement to adjust a feature for a client, is a WordPress hook. If you are not familiar with WordPress hooks, they are known as actions and filters. They allow independent developers like me to modify data that can change content or input values in professional software applications as are the entire suite of Formidable plugins. Formidable has almost 1,100 WordPress hooks available to developers. It's usually just a matter of finding the right filter.

How do I know Formidable has 1,100 WordPress filters? Because I'm just nearing completion of updating the Formidable Masterminds Codex. I have 35 Actions and Filters in the Codex for the User Registration Add-on. Formidable's knowledge base has four listed in the developer documents.

Now, here's the bad news.

None of those 35 hooks will work to solve your requirement, this means you've moved into a situation where your requirement can only be realized by custom code, and I'm not talking about hiring your average WordPress developer. This is going to require someone with advanced PHP skills that understands Object Oriented Programming because the solution may reside in creating a child class. You'd basically have to write your add-on.

Notice I said, "may reside". I can't even be sure if it will work without a proof of concept. A project like that could require a budget of $10k -$25k USD to complete.

When I read the code, there is 1 Formidable filter, but it is not accessible to a developer until after the new user has been activated and it's only to change the success message.

Next we look for public methods. Public methods can receive overrides. This class has five. I focused my attention on do_activation_link(). This controls what happens when the link comes in. It checks to see if a user is logged in and if they are, exits the function. Then it just runs through the activation process and lets the person in. There's no way to interrupt the execution flow.

The functions a developer needs to access are private to the class and the only way to access those are through a child class. I back traced the method trail from do_activation_link() to see what executes earliest. I followed the tracks to get_user_from_activation_link() to get_activation_link_parameter(), the earliest method to execute. All that does is look for the query string and return the required variables. None of these functions can be penetrated.

There simply isn't anyway to do what you want easily without a WordPress hook. You would have to create something that runs before the activation link function in order to expire the link and reroute to your message page. There may be alternatives like exploring WordPress nonce and creating your own link capture code. I honestly don't know, but you'd still have to pay somebody to proof of concept any ideas. Maybe the best route for you is to open a Feature Request ticket with Strategy 11. You'd have to explain exactly what you want to do and why, then let them decide if it should/can be added to their product. Good luck with this.

Making the Best WordPress Plugin even better - Together

Take on bigger projects with confidence knowing you have access to an entire community of Formidable Experts and Professionals who have your back when the going gets tough. You got this!
Join the community
crossarrow-right