当用户访问主页且未关注任何人时,Wordpress 重定向 url

Wordpress redirect url when user access homepage and is not following anyone

因此,我正在开发一个具有以下选项的类似 Behance 的网络。默认情况下,当用户登录时,他会被重定向到主页,以查看包含他关注的人的内容的时间线,但刚刚注册的人在该时间线中看不到任何帖子(因为他还没有关注其他人) ).

因此,我需要将访问主页并关注 0 位用户的已登录用户重定向到 url example.com/#tabber_frontpage_new_posts,以便他看到整体最新帖子,不仅来自以下人的帖子。

在这个主题中,我将像这样计算并打印 'following' 个数字 - 您可能会发现其中一些参数很有用:

<?php echo count( _core::method( '_follow' , 'get_following' , $author_id ) ); ?>

有人能想出一个函数来满足我的需要吗? 谢谢!

我想这就是您要找的:

if ( is_home() && count( _core::method( '_follow' , 'get_following' , $author_id ) ) == 0 ) {
    wp_redirect( '/page/to/redirect/to' );
    wp_die();
}