WordPress Snippets at WPcustoms

Custom password protected text

Change the output text for password protected content on your WordPress site. This snippet function updates the_password_form filter with your html codes.


/**
 * Snippet Name: Custom password protected text
 * Snippet URL: https://wpcustoms.net/snippets/custom-password-protected-text/
 */
  function wpc_password_protected_text($output)
{
    $adminEmail = get_option( 'admin_email' );
    $newPasswordText = 'Password Protected - please email '.antispambot( $adminEmail ).'';
    $output = str_replace('This content is password protected. To view it please enter your password below:', $newPasswordText, $output);

    return $output;
}
add_filter( 'the_password_form', 'wpc_password_protected_text', 999);