B
B
Boris Belov2015-10-26 10:13:46
PHP
Boris Belov, 2015-10-26 10:13:46

How to make certain information visible only for a certain user?

Good morning.
The task seems to be simple, but it seems not so.
For example, on the pages of the site, there is such information that should not be visible to visitors.
But they should not be visible, only from a specific user. '1' ('admin')
That is, for example:

<div>пусто</div>
<div>текст</div>

I saw it - via:
<?php
if ( is_author('admin') ) {
<div>пусто</div>
} else

if ( is_author('') ) {
<div>текст</div>
}
?>

----
Updated!
I have three authors
Иван Пупкин - автор админ
Вася Дедкин  - автор
Петя Папкин - автор

Inside each post I have info about this or that user
Иван Пупкин
год рождения 
город
возраст

I need that when visitors come in (important: not users, but just visitors), they see information about the user ONLY (EXCEPT "ADMIN") , that is, if we go to Vasya Dedkin, then there is info, if in Pupkin it is not.
Yes, I have variables <?php the_author_meta('display_name'); ?>where I can set
<?php the_author_meta('display_name,-5'); ?>, but unfortunately, the entire block and info is stylized, and it needs to be removed by another means.
ps. in my brain it works like this
<?php если это автор поста - то выводить\не выводить {
кусок кода
}
?>

Answer the question

In order to leave comments, you need to log in

2 answer(s)
M
Max, 2015-10-26
@MaxDukov

it is logical to assume that for this you will need to identify the user. And then check that it is this user who is contacting.
google cookies and sessions.

M
Mr Crabbz, 2015-10-26
@Punkie

if(1 == get_current_user_id()){
    	echo "hello world";
  }

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question