Customize Different Password Forms for each WordPress Protected Content

Password Protect WordPress (PPWP) Lite allows users to customize password form with WordPress Customizer. This custom style is applied for password forms of all protected pages and posts.

However, there are some cases where you want to apply different password form style for each content. This article will demonstrate how to achieve it with our PPWP plugin.

Requirements:

This guide requires to customize your child theme’s function.php file by adding our filter ppwp_customize_ppf. This filter will give you the control of all text appearing with our password form.

Add the sample code snippet below to your child theme’s function.php file.

add_filter( 'ppwp_customize_ppf', 'ppwp_customize_password_form', 10, 2 );
function ppwp_customize_password_form( $arr, $post_id ) { 
  //Add conditions to display the following custom password form texts 
  if ( $post_id === 10 || $post_id === 11 ) { 
    $arr['headline'] = 'insert-custom-text-here'; // change headline of password form 
    $arr['description'] = 'insert-custom-text-here''; // change password label 
    $arr['submit_label'] = 'insert-custom-text-here''; // change submit label 
    $arr['password_label'] = 'insert-custom-text-here''; // change password label 
    $arr['error_msg'] = 'insert-custom-text-here''; // change error message which displays when users enter wrong passwords
    $arr['show_password_label'] = 'insert-custom-text-here'; // change label of "show password" button 
return $arr; 
}
Lasted updated on April 7, 2020