New answers tagged

3

The check for a post password happens (for some reason) inside get_the_content(), which seems legit, but actually mixes together two separate concerns. You were right with the statement that there is no way to work around get_the_content() displaying the password form. Here's what the check for the password does in core in detail: if ( empty( $post->...


0

Because I couldn't find an answer on this, I handled it myself by setting my own cookie in the function and checking that. Here is the revised function: function custom_login_init () { $action = isset($_REQUEST['action']) ? $_REQUEST['action'] : 'login'; if ( isset( $_POST['wp-submit'] ) ) { $action = 'post-data'; } else if ( isset( $_GET['reauth'] ) ) ...


0

I've used the following to protect individual pages: First add a field to the Publish Metabox: add_action( 'post_submitbox_misc_actions', 'my_post_submitbox_misc_actions1' ); function my_post_submitbox_misc_actions1(){ echo '<div class="misc-pub-section my-options"> <input type="checkbox" id="fgpsn_protected_content" name="...


-1

You could create a template, which then should be choosen for protected sites. There you just copy the default template, and add a custom login check: <?php if ( !is_user_logged_in() ) : if ( 'failed' == get_query_var( 'login', '' ) ) : <h2 class="red">Wrong credentials !</h2> endif; wp_login_form( $args ); else: the_content(); ...



Top 50 recent answers are included