在主題模板函數 functions.php的<?php下邊添加代碼實現。
// 添加登陸用戶不查看,未登錄的用戶可見
add_shortcode( 'notlogin', 'notlogin_shortcode' );
function notlogin_shortcode( $atts, $content = '' ) {
if ( is_user_logged_in()) {
return $content;
}
$a= '<p style="text-align: left;"><span>本資源是註冊用戶專享的,只有註冊用戶纔可以查看和下載噢~~請您先</span><a href="http://www.example.com/">註冊/登錄 </a></p>';
return $a;
}
在需要加密的內容頭底加入下邊兩段代碼(html編輯器中加入)
[notlogin] [/notlogin]