Zblogphp determines whether the user logs in

original None but Li 2017-06-20 16:37:08

When building a website template, it is sometimes necessary to judge whether a user logs in or whether an administrator logs in. This is not a tutorial, but it is used occasionally. Baidu later saw that Tianxing and Fengyan Blogs have this tutorial, and make a record of their arrival in case of emergency.

zblogphp判断用户登陆.jpg

Judge whether the user logs in

 {if $user.ID>0}                            <!-- Judge whether the user ID is greater than 0 (the registered user ID will be greater than 0... --> Welcome: {$zbp ->user ->StaticName}<-- Here is the content displayed after the user logs in --> {else} <a href="{$host}? Reg">Register</a><! -- Here is what the user does not log in to display --> {/if}

Example:

 {if $user. ID>0} The logged in user can see me! {else} Seeing me means you haven't logged in yet! {/if}

Judge user level

View different content according to different user levels:

ZBlog user level division:

1 ->Administrator

2 ->Website editing

3 ->Author

4 ->Collaborators

5 ->Reviewers

6 ->Tourists

Example 1:

 {if $user.Level < 2} Only administrators above can see it! {/if}

Example 2:

 {if $user.Level == 1} Only administrators can see! {/if}



 Scan WeChat

Related reading

Comment

 visitor visitor
Quick reply: expression:
 cancel
 WeChat QR code
 WeChat QR code
 Alipay QR code