把這個放在functions.php
) v. p' w! J4 X1 [$ ][mw_shl_code=php,false]
3 `# Q& M: U1 n7 k# x' M& Sfunction login_need() {
% }1 H8 U+ B1 \ //global $user_ID; * J8 k8 [# Z6 E9 y" |
$user_ID = get_current_user_id();+ E+ ?" d$ l3 v" h( W$ Q
if ($user_ID == '' && $_SERVER['PHP_SELF'] != "/wp-login.php" && $_SERVER['PHP_SELF'] != "/wp-signup.php") * ^& a$ j+ |" y4 n; C( N
{5 ?) V; h7 n+ _9 ]2 x9 c
header('Location: /wp-login.php');
$ _0 O/ x3 \9 N( ^) e exit;
" P' Q }. i- p# r ^# W- D; @ }
. ?6 D# R' f/ \& |! ?}7 b- R5 R4 @. k* v0 F; {
add_action( 'init', 'login_need' );[/mw_shl_code] Z3 T1 ^0 Y3 k+ Y9 E
7 {- C. `" e; f. [+ H% c
|