Code
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function require_login() { | |
if ( ! is_user_logged_in() && ! preg_match( '/^(wp-login\.php|async-upload\.php)/', basename( $_SERVER['REQUEST_URI'] ) ) && ! ( defined( 'DOING_AJAX' ) && DOING_AJAX ) && ! ( defined( 'DOING_CRON' ) && DOING_CRON ) ) { | |
auth_redirect(); | |
} | |
} | |
add_action( 'init', 'require_login' ); | |
?> |
Note
Description | ログインユーザー以外はWebサイトを閲覧できないようにする事で簡易的な会員サイトを構築できる |
---|---|
WordPress Ver. | 3.3.1 |
Via | WordPressの表示をログインユーザーに限定する |