my code stock.com

Tobias Hopp

WordPress Lock / Kompletter Lock der Seite
by Tobias Hopp

Code um eine komplette WP Installation per Login dicht zu mache.

Snippet options

Download: Download snippet as wordpress-lock-kompletter-lock-der-seite.php.
Copy snippet: For this you need a free my code stock.com account.
Embed code : You will find the embed code for this snippet at the end of the page, if you want to embed it into a website or a blog!

<?php
// Functions.php


add_action( 'wp', 'member_only_site' );
function member_only_site( ) {
    if ( ! is_user_logged_in( ) ) {
          auth_redirect();
    }
}

function the_login_message( $message ) {
    if ( empty($message) ){
        return "<p>Willkommen im Reifen Gundlach Intranet. Bitte logge Dich ein um Fortzufahren.</p>";
    } else {
        return $message;
    }
}
add_filter( 'login_message', 'the_login_message' );


/* //////////////////////////////////////////////////////////////////////////////////////////// */

// Oder diese Option:

function password_protected() {
    if ( !is_user_logged_in() ) {
        auth_redirect();
    }
}
add_action('template_redirect', 'password_protected');
add_action('do_feed', 'password_protected');

Create a free my code stock.com account now.

my code stok.com is a free service, which allows you to save and manage code snippes of any kind and programming language. We provide many advantages for your daily work with code-snippets, also for your teamwork. Give it a try!

Find out more and register now

You can customize the height of iFrame-Codes as needed! You can find more infos in our API Reference for iframe Embeds.