表示当前用户未注销(仍在同一登录会话中)的条件语句?

时间:2013-06-26 作者:whiteletters in blankpapers

提前感谢您抽出时间。

我想执行以下条件if:

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

{
Do_something;
}
如何使用Codex函数表示它?我想将其添加到以下内容中if 但这是徒劳的。

if (
    is_single() 
    && !empty($current_user)
    && $post->post_author == $current_user->ID
  ) {
    remove_action(\'wp_head\', \'process_postviews\');
  }
非常感谢您一如既往的帮助。

2 个回复
SO网友:TheDeadMedic
if ( is_user_logged_in() ) {
    echo \'Hello \' . wp_get_current_user()->display_name;
}
SO网友:whiteletters in blankpapers

这个问题的解决方案在下面的链接中,由HeadMedic提供。它使用cookies原理和一些数组管理。

Prevent multiple counts by same user - WP PostViews plugin

请注意,有链接到该帖子的帖子,这有助于了解整个情况。

祝你好运

结束