Quantcast
Channel: WordPress.org Forums » All Topics
Viewing all articles
Browse latest Browse all 59525

Customized text on password protected pages not working.

$
0
0

Replies: 0

I’m trying to customize the text on two password-protected page. The code in place currently is working for one of the password-protected pages:

function my_password_form() {
    global $post;
    $label = 'pwbox-'.( empty( $post->ID ) ? rand() : $post->ID );
    $o = '<form action="' . esc_url( site_url( 'wp-login.php?action=postpass', 'login_post' ) ) . '" method="post">
    ' . __( "<strong>Registration for the Law Enforcement Portal is password protected.</strong> If this is your first time visiting the Law Enforcement Portal, please enter the password provided to you in the password field below to fill out and submit your registration.<br><br>If you have not yet been provided with a password to register for the Portal, please contact beth@acefonline.org.<br>" ) . '
    <label for="' . $label . '">' . __( "Password:" ) . ' </label><input name="post_password" id="' . $label . '" type="password" size="20" maxlength="20" /><input type="submit" name="Submit" value="' . esc_attr__( "Submit" ) . '" />
    </form>
    ';
    return $o;
}
add_filter( 'the_password_form', 'my_password_form' );

But when I try the following code, the messages do change, however, once the password is entered on either page and “submit” is clicked, the user gests a 404 page. What am I missing?

add_filter( 'the_password_form', 'custom_password_protected_form' );

function custom_password_protected_form($output) {     
   global $post;
      
   switch ($post->post_name) {         
       case 'register-login':             
          $replacement_text = <strong>Registration for the LE Portal is password protected.</strong> If this is your first time visiting the LE Portal, please enter the password provided to you in the password field below to fill out and submit your registration.<br><br>If you have not yet been provided with a password to register for the Portal, please contact beth@xxxx.org.<br>';             
         break;         
     case 'dealer-register-login':             
        $replacement_text = <strong>Registration for the DE Portal is password protected.</strong> If this is your first time visiting the DE Portal, please enter the password provided to you in the password field below to fill out and submit your registration.<br><br>If you have not yet been provided with a password to register for the Portal, please contact info@xxxx.org.<br>';         
    case 'default':             
       $replacement_text = '';     
}      

  if (!empty($replacement_text)) $output = str_replace(__( 'This content is password protected. To view it please enter your password below:' ), $replacement_text, $output);     
  return $output; 
} 

Viewing all articles
Browse latest Browse all 59525

Trending Articles