loading...
Cover image for The Facepalming Dev πŸ€¦β€β™‚οΈ #3

The Facepalming Dev πŸ€¦β€β™‚οΈ #3

jsn1nj4 profile image JSn1nj4β€β€πŸ‘¨β€πŸ’» ・2 min read

Preface

I'm primarily a WordPress user at my day job; I'm not sure whether this does or doesn't help my case since being WordPress-Primary means living in the Land of Plugins, but here goes....

The setup

As with all WordPress sites I work on, most tasks are centered around content and there's a page builder involved. But unlike most WP projects, this one does have at least a handful of actions and filters that I've added to the theme.

On this project, there's a login page. Anyone can use it, but it's meant for users of a specific kind of role. This doesn't prevent it working if your user doesn't have this role, but it's important.

Once this type of user logs in, they then have access to a page full of resources that only this type of user is allowed access to (along with Editors and Admins, who do need to be able to edit content).

Today's Episode

The task I happened to be focused on was redirecting this particular kind of user if they were trying to access the login page while logged in. Sounds simple enough, right?

So I went on a journey that involved searching through hooks, looking for similar solutions, dumping the WP instance for crying out loud... This whole thing lasted about 2.5 hours.

After much work, finally deciding to give up, and beginning to log my (lack of) progress in this area, something dawned on me...

You see, I had created this login page the week before. And in the process of creating this login page, I had 1) installed a powerful redirect-building plugin that 2) included adding URL- and role-specific conditions and 3) had actually created/tested this particular redirect... I ended up deactivating it for a reason that'll require too much explanation for this article...

But yes, the working solution already existed and I was the one who implemented it.

I also had the equivalent of 6.5 cups of coffee today and that apparently didn't help me (or maybe it made things worseβ€”who knows).

Wrap-up

So... That's my facepalm-inducing story this time around. Anyone care to share their own stories below?

Bonus facepalms

  1. I was rushing to publish this towards the end of writing and forgot to set published: true. πŸ€¦β€β™‚οΈ
  2. The previous title of this one was "The Facepalming Dev πŸ€¦β€β™‚οΈ #2", but I already posted #2 last year... So this is now #3. πŸ€¦β€β™‚οΈ

I hope I'm finally adding bonus facepalms to this. I think I need to go to bed soon.

Discussion

markdown guide