Creating a custom directory template

Sometimes when building a site or theme with WP User Manager, you will want to create different design/templates for each user directory of your website. Luckily WPUM allows you to do this and it's very easy to do.

Register your own template:

During the creation of a new directory, you will see a series of options, including the selection of a template, which by default only displays the option "default template".

Adding a new option for that setting is very easy through the built-in filters. We will be using the filter  wpum_get_directory_templates - You can add the snippet below in your theme's functions.php file (bottom).

As you can see in the above code, we're adding a new template to the $templates variable. In the above example, "custom" is the key of the template, and "My Template" is the label of the option.

Create the template files:

Now that you have registered the new template, you will need to create the template files. 

  • Duplicate the user-directory.php template file of the plugin and place it into the "wpum" subfolder of your theme. If the folder doesn't exist, create it.
  • Rename the user-directory.php file to user-directory-custom.php - where "custom" is the name assigned to the template through the filter.
  • Your directory will now be loading your custom template file. You can make your customization into that file.