Pro Faceoff

  • About
  • Blog
  • Statistics
    • WordPress Plugin Statistics 2021
    • WordPress Plugin Facts 2021
    • WooCommerce Statistics 2021
    • Newsletter Sign-up Ideas
    • Form Abandonment Statistics
    • Social Media Statistics
    • Shopify vs WooCommerce SEO
    • Digital Signature Market Share Statistics 2021
    • Google Trends
  • Write For Us
  • Contact

Updated on by thinhnp

How to Create a Custom Login Form for Password Protect WordPress plugin?

Password Protect WordPress is one of the best plugins to apply authentication policies for WordPress website with the useful features. Besides that, it also offers us the ability to customize the Login Form. In this article, we’ll guide you the two easy ways to achieve it.

Idea

First of all, let’s have a look at the default login form’s HTML structure.

#1 is a fixed parent element that wraps our child elements.

#2 is a fixed action “ppwp_password_action” which the plugin defined where to handle the form request.

#3 is a place where we can customize our password input and submit button.  We can also add here anything we want. Please keep in mind, the password input’s name must be “post_password”

#4 is a required hidden input that contains the post’s ID.

The plugin helps us to customize the #3 by defining the hook, namely ppwp_customize_password_form

Using ppwp_customize_password_form hook

In this part, we will use the ppwp_customize_password_form hook to decorate our login form.

The hook will pass us two parameters $element is default element defined by the plugin and $post_id is the current protected post/page which user is trying to access its content. In this function, we added some wrapper div and gif image to improve the UI. The two required elements password input (with the input name is post_password) and submit button still keep remain at line 16 and 19. Here is our custom Login Form, it’s better then, isn’t it?

How about some customers are using the WordPress hook, namely the_password_form to customize the WordPress Login Form? Good news is the Protect Password plugin also supports this hook.

Using the_password_form WordPress hook

 

When using the_password_form hook, you need to keep in mind that we will replace the whole Login Form’s HTML structure.  These are some rules we need to follow in order to keep the Protect Password plugin can work like a charm with our custom code.

1. The login form action must be ppwp_password_action

2. The input password’s name must be post_password

3. The input hidden’s name post_id must be added

The following snippet will show us how we apply these above rules.

The #1 rule is applied at line 6, we configure form action to be  get_option( ‘siteurl‘ ) . ‘/wp-login.php?action=ppwp_password_action

The #2 rule is implemented at line 23, our input password’s name is post_password

The #3 rule is easy to find out at line 24

And then, we have our cool login form.

[Updated for version 1.0.6.2]

From version 1.0.6.2 we added a error message when user entered a wrong password. In order to display it in your own login form, please use the third parameters $wrong_password_message. We also add a new hook ppwp_text_for_entering_wrong_password that you can customize the error message. Cool right?

So, what are you waiting for? Let’s rock and enjoy the Password Protect WordPress plugin.

 

CategoriesInternal document Tagsform, login, password

Post navigation

Previous PostPrevious How to configure Cross Origin Resource Sharing (CORS) on S3 Bucket?
Next PostNext Dropbox Shared Link Solution
Share

Join Our Email Lists

Stay up to date with the latest WordPress stuff from us!

Recent posts

  • The Fastest Ways to Add Breadcrumbs to WordPress December 24, 2022
  • The Easiest Ways to Transfer Contact Form 7 to Google Sheet December 16, 2022
  • How to Easily Edit Navigation Bar WordPress 101 December 8, 2022

Categories

  • Digital Signatures (12)
  • News (1)
  • Shopify (18)
  • WooCommerce Products (6)
  • WordPress Forms (58)
  • WordPress Plugins (22)
  • WordPress Tips (56)

Topics

  • eCommerce SEO
  • Electronic Signatures
  • form
  • login
  • password
  • Shopify Free Shipping
  • Transparent Signatures
  • WooCommerce
  • WooCommerce one-page checkout

ProFaceoff & BWPS

We are the team behind Prevent Direct Access (PDA) Gold, Password Protect WordPress (PPWP) Pro, S3 Smart Upload (SSU), and more.

We believe anyone with passion can make a difference in this world. And we want to walk the talk through various products of our own.

WordPress Statistics

  • WooCommerce Statistics
  • WordPress Plugin Statistics

WordPress Forms

  • Redirect Contact Form 7 to Thank You Page
  • 9 Tips to Create Contact Us Page
  • 10 Tricks to Stop WordPress User Registration Spam

Partners

  • PDA Gold
  • Gold Extensions
  • PPWP Pro
  • Pro Membership
Secure Payment with Prevent Direct Access supports PayPal & Stripe payment
Copyright © 2016-2025 BWPS, LLC.