最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

php - Display specific page if user signed in

programmeradmin0浏览0评论

I have a business directory website. I'd like to know how to create a page display condition. Basically, when clicking on the "add a listing" button, how do I make non-logged-in users be directly taken to the login/sign up page instead of the "choose a listing type" page?

(Currently, all users are taken to the "choose a listing type" page, and if not logged in, after choosing the type are asked to sign-in/sign up and then taken BACK to the "choose a listing type" page. It's a lot of unnecessary back-and-forths.)

I have a business directory website. I'd like to know how to create a page display condition. Basically, when clicking on the "add a listing" button, how do I make non-logged-in users be directly taken to the login/sign up page instead of the "choose a listing type" page?

(Currently, all users are taken to the "choose a listing type" page, and if not logged in, after choosing the type are asked to sign-in/sign up and then taken BACK to the "choose a listing type" page. It's a lot of unnecessary back-and-forths.)

Share Improve this question edited Jul 30, 2019 at 22:42 Castiblanco 2,1947 gold badges20 silver badges26 bronze badges asked Jul 30, 2019 at 22:35 Myriam RichardMyriam Richard 1 1
  • What is the add a listing button and how is it implemented in code? – Tom J Nowell Commented Jul 30, 2019 at 23:08
Add a comment  | 

1 Answer 1

Reset to default 0

You can use this filter so when user comes into your website so you will redirect to them on specific page and display that specific page.

function user_redirect_page() {
    return site_url().'your-page-slug';
} 
add_filter('login_redirect', 'user_redirect_page');
发布评论

评论列表(0)

  1. 暂无评论