Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**********************************************
- * Custom Password Form
- **********************************************/
- add_filter( 'the_password_form', 'custom_password_form' );
- function custom_password_form() {
- global $post;
- $label = 'pwbox-'.( empty( $post->ID ) ? rand() : $post->ID );
- $o = '<form class="protected-post-form form-inline" action="' . get_option('siteurl') . '/wp-login.php?action=postpass" method="post">
- <input class="input-medium" placeholder="Password" name="post_password" id="' . $label . '" type="password" /> <button type="submit" name="Submit" class="btn btn-primary">Submit</button>
- </form><p>This page is password protected. <a href="mailto:[email protected]">Contact us</a> in case you have lost your password or want to register for access. Thank you</p>
- ';
- return $o;
- }
- /**
- * Add a message to the password form.
- *
- * @wp-hook the_password_form
- * @param string $form
- * @return string
- */
- add_filter( 'the_password_form', 'wpse_71284_custom_post_password_msg' );
- function wpse_71284_custom_post_password_msg( $form )
- {
- // No cookie, the user has not sent anything until now.
- if ( ! isset ( $_COOKIE[ 'wp-postpass_' . COOKIEHASH ] ) )
- return $form;
- // We have a cookie, but it doesn’t match the password.
- $msg = '<div class="alert alert-error"><button type="button" class="close" data-dismiss="alert">×</button><p>The password you submitted was incorrect.</p></div>';
- return $msg . $form;
- }
- /**
- * Remove Protected: from Title
- */
- add_filter('protected_title_format', 'blank');
- function blank($title) {
- return '%s';
- }
Advertisement
Add Comment
Please, Sign In to add comment