Site Overlay

Obi LearnDash Redirect

I started this as a small custom code snippet.

But it had disadvantages:

  1. It depended highly on the active theme. If the theme was switched off, the code got disabled.
  2. The logic needed more work. It didn’t validate the existence of LearnDash. If LearnDash were deactivated, it would start throwing errors and causing conflicts.
    Not to mention that it didn’t check if the Button URL value was empty.
  3. Extensibility was harder.

I know I can make a simple check with the is_plugin_active() function and add that to the snippet, as well as check that the Button URL value is not empty to continue execution, but that was just about it.


Making this code into a plugin brings me the opportunity to apply Object Oriented Design.

This first version of the plugin has been an amazing learning experience. And it is just the beginning. I’m using it as the jumpstart to develop more ideas I have in mind.

And also, the involvement of PHP Composer to manage dependencies (just one at the moment) makes including code a breeze.

For the next update, I plan to add support for Groups in LearnDash. What this means is that anyone who sells Groups on their LearnDash website and is using sales pages, for that matter, will have the same redirect feature as in courses. A very similar feature.

The idea is to write an abstract class with all the common properties and methods between both features, then rewrite the existing class extending that abstract class. Some conditions are different for each case, so I’ll also write a new class centered on the new feature.

That way, I can use similar features in each, avoiding repeating myself and also defining differences in each class.

Check the code here: