Software Engineering in WordPress, PHP, and Backend Development

Category: Articles (Page 17 of 258)

Personal opinions and how-to’s that I’ve written both here and as contributions to other blogs.

Using Ray in WordPress Development: An Example of Classic Debugging

TL;DR: This final article will demonstrate how to use Ray in WordPress as an example of classic debugging.

No, it’s not the same as something such as Xdebug, but it demonstrates what we can do such as changing variables on the fly and changing the course of execution.


⚠️ If you’ve not already set up your environment, please read this post and make sure you have the free version of Ray installed.

Continue reading

Quick Tip: Find WordPress Users by Metadata

TL;DR: Here’s how you can use SQL to find WordPress users by metadata. This is useful when you have information such as their first name and last name and want to retrieve the full WP_User.


WordPress provides a number of functions that make it easy to retrieve a user based on certain information. One of the most popular functions (or most useful, maybe?) is get_user_by.

However, what if you’re working on a system that maintains the user’s first name and last name or some other type of data point in the usermeta table and you want to use that to retrieve the user’s information?

Continue reading

Quick Tip: Programmatically Authenticate a User

TL;DR: Here’s how you can programmatically authenticate a user into WordPress as long as you have a verified user ID for said user.


Earlier this week, I shared how to import necessary core files to programmatically manage users in the administration area of WordPress. Along those same lines, if you’re working with a third-party service for login and authentication, it may be useful to know how to programmatically redirect to the administration area once you have a valid user ID.

Continue reading

How to Dynamically Load Classes by Namespace in PHP

TL;DR: To dynamically load classes by namespaces in PHP, you need a Registry, and a way to parse the concrete files from a directory based on its namespace.


Whenever I’m working on a project that has an object-oriented code base and that uses Subscribers and Services, I often use a Registry. This makes it easy to

  • register the subscribers with the core application whenever the code runs,
  • de-couple any Service classes so they can be tested or even run isolation,
  • and maintain the code base whenever something has to be added or taken away.

One challenge with this approach though, at least in PHP, is that I’ve found myself having to go back into the Registry and set a reference to a given Subscriber whenever I want to add it (or remove it whenever I want to, you know, remove it).

Ideally, I want my registry to know where the subscribers are and how to set them up. This way, I can focus on working on the rest of the code.

Continue reading
« Older posts Newer posts »

© 2025 Tom McFarlin

Theme by Anders NorenUp ↑