Record how WordPress judges whether a reviewer is a registered user

» WordPress » Record how WordPress judges whether a reviewer is a registered user

Judge whether the reviewer is registered or logged in on the site by judging the user ID to realize the judgment of a special content

记录下WordPress如何判断评论者是否为注册用户-极客公园

preface

Scenario requirements

First, let's talk about the usage scenario. There is an input box for the website in the comment, but if the user logs in, there is no input box for the website. I think if the commenter is a registered user, there is no input box for the website. The name is linked to the user's home page. If you are not a registered user, you can connect to the website he entered.

 <? php if ($comment->user_id !== '0') { echo '<span class="c-author"><a target="_blank" href="' . get_author_posts_url($comment->user_id) . '">' .  get_comment_author() . '</ a></span>'; } else { echo '<span class="c-author">' .  get_comment_author_link() . '</ span>'; } ?>

Postscript

In fact, after looking at the following data table, it is found that if the user ID is 0, it is an unregistered user, and the registered user ID is a specific user ID. Record it

--End--

Post reply

Your email address will not be disclosed. Required items have been used * tagging

One Reply to "Record how WordPress judges whether a reviewer is a registered user"