Thank you in advance for your time.

I want to perform the following conditonal if:

if (current user didnt log out and is in the same login session )


How to express it using Codex functions? I want to add it to the following if but in vain.

if (
    && !empty($current_user)
    && $post->post_author == $current_user->ID
  ) {
    remove_action('wp_head', 'process_postviews');

Your usual help is always appreciated.

if ( is_user_logged_in() ) {
    echo 'Hello ' . wp_get_current_user()->display_name;
| improve this answer | |
  • Thank you for your quick feedback to my post. In fact, I already use the if statement you provided since my website is already a private community. The problem I have is that I am using a plugin that displays post number of views and it is incremented even if the same user refreshes the page. Could you please check the attached link? – whiteletters in blankpapers Jun 26 '13 at 11:27
  • Your code snippet & your question are trying two different things. Do you want to ensure that one user = one view, regardless how many times they refresh? Or do you want to exclude view counts by the author of the post? – TheDeadMedic Jun 26 '13 at 11:35
  • I want to ensure one user = one view, during one login. Excluding view counts by the author is already performed thanks to S_HA_DUM answer in linked post. In that hack we used remove_action. – whiteletters in blankpapers Jun 26 '13 at 11:36
  • Then you'll need a bit more logic than simply removing the action. Can you link to the plugin you're using? – TheDeadMedic Jun 26 '13 at 11:38
  • 1
    This really warrants a new question. I suggest something like "WP Postviews - Prevent multiple counts by same user", then briefly explain your situation in a little more detail & link to the plugin. – TheDeadMedic Jun 26 '13 at 11:48

the solution to this issue is in the link below, provided by TheDeadMedic. It uses the cookies principle and some array management.

Prevent multiple counts by same user - WP PostViews plugin

Note that the there are linked posts to this post, that can be helpful to understand the whole situation.

Good luck.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.