• Hi,

    i have a feature request. Not sure if this is the way to go about it but anyway here it is.
    I’d like the translation to differ between post and pages when you password protect it.
    Today it says:
    This post is password protected. To view it please enter your password below:

    Would like it to differ on post and pages. For example:
    This post is password protected. To view it please enter your password below:
    This page is password protected. To view it please enter your password below:

    Best regards,
    Marcus

Viewing 4 replies - 1 through 4 (of 4 total)
  • That could be dealt with via your theme.

    Thread Starter Marcus Abrahamsson

    (@cobraeyes)

    ok, via the page/post template?

    No – via your theme’s functions.php file and the the_password_form filter. Something like:

    function my_password_form() {
    	global $post;
    	if(is_page() ) $post_or_page = 'page';
    	else $post_or_page = 'post';
    	$label = 'pwbox-'.(empty($post->ID) ? rand() : $post->ID);
    	$output = '<div class="password-form"><p class="protected-text">';
    	 $output .= sprintf( __('This %1$s is password protected. To view it, please enter your password below:'), $post_or_page);
    	$output .= '</p><form action="' . esc_url( site_url( 'wp-login.php?action=postpass', 'login_post' ) ) . '" method="post">
    	<p><label for="' . $label . '">' . __('Password:') . ' </label> <input name="post_password" id="' . $label . '" type="password" size="20" /> <input type="submit" name="Submit" value="' . esc_attr__('Submit') . '" /></p></form></div>';
    	return $output;
    }
    add_filter('the_password_form','my_password_form');

    should work.

    Thread Starter Marcus Abrahamsson

    (@cobraeyes)

    Thx alot! worked like a charm! 😉

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Feature Request: Post or page if password protected’ is closed to new replies.