admin管理员组文章数量:1335122
i'm a young informatic engineer student who is developing his first wordpress website. It is a booking website when a client can see the available hours in certain local and book it, and the local can login with his account to check the books that he has and make new ones (for example, the ones booked by phone). What i want is to display different content depending on the account which is logged in. For example, the local can see and modify all the schedule, but the client can only see the available hours and book it. I dont know if it is possible, or if it is so difficult, so i would love any help or advice. Thank you guys.
i'm a young informatic engineer student who is developing his first wordpress website. It is a booking website when a client can see the available hours in certain local and book it, and the local can login with his account to check the books that he has and make new ones (for example, the ones booked by phone). What i want is to display different content depending on the account which is logged in. For example, the local can see and modify all the schedule, but the client can only see the available hours and book it. I dont know if it is possible, or if it is so difficult, so i would love any help or advice. Thank you guys.
Share Improve this question asked Jun 1, 2020 at 17:50 javier romerojavier romero 111 bronze badge 3- A quick tip for getting great answers: Consider starting by expanding on the summary you put in the title. Explain how you encountered the problem and any difficulties in solving it yourself. The first paragraph is the second thing most readers will see, so make it a good one. Check our guide to asking good questions if you need to. – Matthew Brown aka Lord Matt Commented Jun 1, 2020 at 19:05
- This is a fairly broad question - more specific ones tend to get more responses. Are you wanting people to log in and manage all this on the back end, or trying to keep it all on the front end? There may already be plugins available that can do what you're needing, it may just take some research and experimenting. You could also build your own theme if you're wanting everything managed on the front end, and use simple conditionals checking the current user's capabilities. – WebElaine Commented Jun 1, 2020 at 19:06
- It's not that broad. Surely the answer is just to check capabilities? – Matthew Brown aka Lord Matt Commented Jun 1, 2020 at 19:13
1 Answer
Reset to default 0You are going to want to look at a few things. First, the WP_user object which will enable you to check if the user is even logged in. But you can also check capabilities with the has_cap
method.
You can even define your own capabilities and apply them to users.
Then you would do something along these lines:
<?php
$user = wp_get_current_user();
if($user->exists()){
// logged in user
if( $user->has_cap('edit_users') ){
// user can edit users
}else{
// this user cannot do that
}
}else{
// anon user
}
本文标签: usersDisplaying different inpage content to clienteadmin
版权声明:本文标题:users - Displaying different in-page content to clienteadmin 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742383190a2464503.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论