Join Carrie Dils for an in-depth discussion in this video Customizing the WordPress login page, part of Advanced WordPress: Action and Filter Hooks.
- [Carrie] I'd like to take a look at what we've learned so far and use it to build a simple WordPress plugin that modifies this login page. Note that we're not going to use any code that I've previously shown in this course. We'll be creating some fresh files from scratch, and those are going to be available to you in the course exercise files if you'd like to follow along. So we've already spent some time looking at this login page, and we know that WordPress gives us lots of actions and filters we can use to modify this page and how it behaves. I'm going to start by finding my local installation of WordPress in my file system.
Depending on how you installed WordPress, this location will most likely be different for you. If you need to pause and take a moment to find it, go right ahead. So here I am at the root of my WordPress site, and I'm going to navigate to the wp content plugins folder. And this is where I'm going to create my custom plugin. I'm going to go ahead and create a new folder and name it custom wp login. Now with that folder created, I'm going to go ahead and open up my code editor, where I'm already looking at the folder structure for this install, and here I can see that my new plugin folder is there.
And I want to create a file for this. And I'm going to call it custom-wp-login.php. Clear that out, and let's go ahead and start setting up our file. So first that opening php tag, and now for some basic header information. I'm going to give my plugin an official name, Custom WP Login.
And we'll just give it a version number of 0.1. I'm going to list myself as the author, of course you could list yourself as the author for yours, and I'm going to license it as GPL2 or greater. Finally, I'm going to give it a text domain, and I'll just do the C for custom WP and L for login. I'm going to go ahead and save that. There's definitely additional information that you could put in a real plugin header, and you'd want to reference this plugin handbook on wordpress.org to see what all those are.
So since I've saved my plugin file, if I go log in to my WordPress admin, and go to plugins, I should see my plugin there. So I'm going to go ahead and activate it. So at this point, all we've done is created a plugin folder, created a plugin file within that folder, given it some basic header information, and then confirmed that we'd activated it in our WordPress install. With that foundation, we're ready to start adding some customizations.
- Actions and filters explained
- Identifying available hooks and filters
- Looking at load order
- Understanding callback functions
- Creating custom hooks
- Using third-party hooks
- Building a new WordPress plugin with filters and actions