• Resolved mores

    (@mores)


    Hey guys and gals,
    I’ve failed to find the way to change the layout of password protected pages.
    Where do I change the “this post is protected” message, how do I add a contact form so people can write and request a password … help 🙂

Viewing 5 replies - 1 through 5 (of 5 total)
  • Thread Starter mores

    (@mores)

    Well no thanks to you people 😉 I managed to find the solution myself. There is no theme file that needs editing, so you need to add a filter to your functions.php file in the theme directory. Use this

    function replace_the_password_form($content) {
      global $post;
      // if there's a password and it doesn't match the cookie
      if ( !empty($post->post_password) && stripslashes($_COOKIE['wp-postpass_'.COOKIEHASH])!=$post->post_password ) {
        $output = '
    
        <form action="'.get_option('siteurl').'/wp-pass.php" method="post">
          '.__("This post is password protected. To view it please enter your password below:").'
    
            <label for="post_password">Passwort:</label>
            <input name="post_password" class="input" type="password" size="20" />
            <input type="submit" name="Submit" class="button" value="'.__("Submit").'" />
    
        </form>
    
        ';
        return $output;
      }
      else return $content;
    }
    add_filter('the_content','replace_the_password_form');

    Obviously, now you can edit it to your liking.

    I found this info on this site:
    http://simbo.de/blog/wordpress/wordpress-tipp-passwort-formular-bei-geschuetzten-beitraegen-anpassen/

    awesome, thanks for the help!

    Mores you rock!

    This is good stuff… you’re the man for posting it…

    NO! You are two men!

    hehe…

    thanks a bunch

    fedmich

    (@fedmich)

    exactly what I need right now!
    Thanks a lot Mores 🙂

    There is no theme file that needs editing, so you need to add a filter to your functions.php file in the theme directory

    Well, yes there is 🙂

    You will find the form in /wp-includes/post-template.php it looks like this:

    function get_the_password_form() {
    	global $post;
    	$label = 'pwbox-'.(empty($post->ID) ? rand() : $post->ID);
    	$output = '<form action="' . get_option('siteurl') . '/wp-pass.php" method="post">
    	' . __("This post is password protected. To view it please enter your password below:") . '
    
    	<label for="' . $label . '">' . __("Password:") . ' <input name="post_password" id="' . $label . '" type="password" size="20" /></label> <input type="submit" name="Submit" value="' . __("Submit") . '" />
    
    	</form>
    	';
    	return apply_filters('the_password_form', $output);
    }

    Solution found here: http://www.dagondesign.com/articles/show-the-intro-to-password-protected-posts-in-wordpress/

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘password protected – change message’ is closed to new replies.