When visiting /user/ID how to allow users to only visit their own user page
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty{ margin-bottom:0;
}
up vote
0
down vote
favorite
I created a Twig template for the user account /user/ID
page on Drupal 8.
How to display this template only if it is the account page of the current user?
For example if I go to the page of my account, I can display the page. If I go to another user's account page, a 403 error should be displayed.
8 theming users
New contributor
add a comment |
up vote
0
down vote
favorite
I created a Twig template for the user account /user/ID
page on Drupal 8.
How to display this template only if it is the account page of the current user?
For example if I go to the page of my account, I can display the page. If I go to another user's account page, a 403 error should be displayed.
8 theming users
New contributor
Welcome to Drupal Answers! We love to help you. What you are asking for, it has nothing to do with Twig or templates in the first place. So I reworded your question and removed the Twig template from it.
– leymannx
yesterday
1
Uncheck the permission that deals with viewing user profiles? That should solve it? Unless that affects the current user too.
– Kevin
yesterday
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I created a Twig template for the user account /user/ID
page on Drupal 8.
How to display this template only if it is the account page of the current user?
For example if I go to the page of my account, I can display the page. If I go to another user's account page, a 403 error should be displayed.
8 theming users
New contributor
I created a Twig template for the user account /user/ID
page on Drupal 8.
How to display this template only if it is the account page of the current user?
For example if I go to the page of my account, I can display the page. If I go to another user's account page, a 403 error should be displayed.
8 theming users
8 theming users
New contributor
New contributor
edited yesterday
leymannx
6,46142457
6,46142457
New contributor
asked yesterday
user90437
42
42
New contributor
New contributor
Welcome to Drupal Answers! We love to help you. What you are asking for, it has nothing to do with Twig or templates in the first place. So I reworded your question and removed the Twig template from it.
– leymannx
yesterday
1
Uncheck the permission that deals with viewing user profiles? That should solve it? Unless that affects the current user too.
– Kevin
yesterday
add a comment |
Welcome to Drupal Answers! We love to help you. What you are asking for, it has nothing to do with Twig or templates in the first place. So I reworded your question and removed the Twig template from it.
– leymannx
yesterday
1
Uncheck the permission that deals with viewing user profiles? That should solve it? Unless that affects the current user too.
– Kevin
yesterday
Welcome to Drupal Answers! We love to help you. What you are asking for, it has nothing to do with Twig or templates in the first place. So I reworded your question and removed the Twig template from it.
– leymannx
yesterday
Welcome to Drupal Answers! We love to help you. What you are asking for, it has nothing to do with Twig or templates in the first place. So I reworded your question and removed the Twig template from it.
– leymannx
yesterday
1
1
Uncheck the permission that deals with viewing user profiles? That should solve it? Unless that affects the current user too.
– Kevin
yesterday
Uncheck the permission that deals with viewing user profiles? That should solve it? Unless that affects the current user too.
– Kevin
yesterday
add a comment |
1 Answer
1
active
oldest
votes
up vote
5
down vote
Go to admin path : /admin/people/permissions
and uncheck the permission named 'View user information' for the concerned roles, then save.
This does not affect users when they are on their own account page.
I did the following test, created two new users (4 and 5 in my case) :
- user
4
can accessuser/4
page but has "Access denied" foruser/5
page. - user
5
can accessuser/5
page but has "Access denied" foruser/4
page. - both users
4
and5
have "Access denied" foruser/1
page.
@EricLavault I need to display user information on some parts of my site. I'm just trying to ban the account page.
– user90437
23 hours ago
@user90437 Yes, and ..? You asked a question, and this question got a very clear answer that received several upvotes from the community, meaning other people here including me would be totally satisfied with this answer. If there is anything that you don't understand, please elaborate. Otherwise, you should accept the answer, putting the green flag for other people wondering how to allow users to only visit their own user page, why not ?
– EricLavault
19 hours ago
@EricLavault So I had to leave my original question
– user90437
18 hours ago
@user90437, I think so too this answers all of your question. If you want to display user information on other parts of your site you can build a View. Views doesn't check for permissions unless instructed to do so.
– 4k4
7 hours ago
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
5
down vote
Go to admin path : /admin/people/permissions
and uncheck the permission named 'View user information' for the concerned roles, then save.
This does not affect users when they are on their own account page.
I did the following test, created two new users (4 and 5 in my case) :
- user
4
can accessuser/4
page but has "Access denied" foruser/5
page. - user
5
can accessuser/5
page but has "Access denied" foruser/4
page. - both users
4
and5
have "Access denied" foruser/1
page.
@EricLavault I need to display user information on some parts of my site. I'm just trying to ban the account page.
– user90437
23 hours ago
@user90437 Yes, and ..? You asked a question, and this question got a very clear answer that received several upvotes from the community, meaning other people here including me would be totally satisfied with this answer. If there is anything that you don't understand, please elaborate. Otherwise, you should accept the answer, putting the green flag for other people wondering how to allow users to only visit their own user page, why not ?
– EricLavault
19 hours ago
@EricLavault So I had to leave my original question
– user90437
18 hours ago
@user90437, I think so too this answers all of your question. If you want to display user information on other parts of your site you can build a View. Views doesn't check for permissions unless instructed to do so.
– 4k4
7 hours ago
add a comment |
up vote
5
down vote
Go to admin path : /admin/people/permissions
and uncheck the permission named 'View user information' for the concerned roles, then save.
This does not affect users when they are on their own account page.
I did the following test, created two new users (4 and 5 in my case) :
- user
4
can accessuser/4
page but has "Access denied" foruser/5
page. - user
5
can accessuser/5
page but has "Access denied" foruser/4
page. - both users
4
and5
have "Access denied" foruser/1
page.
@EricLavault I need to display user information on some parts of my site. I'm just trying to ban the account page.
– user90437
23 hours ago
@user90437 Yes, and ..? You asked a question, and this question got a very clear answer that received several upvotes from the community, meaning other people here including me would be totally satisfied with this answer. If there is anything that you don't understand, please elaborate. Otherwise, you should accept the answer, putting the green flag for other people wondering how to allow users to only visit their own user page, why not ?
– EricLavault
19 hours ago
@EricLavault So I had to leave my original question
– user90437
18 hours ago
@user90437, I think so too this answers all of your question. If you want to display user information on other parts of your site you can build a View. Views doesn't check for permissions unless instructed to do so.
– 4k4
7 hours ago
add a comment |
up vote
5
down vote
up vote
5
down vote
Go to admin path : /admin/people/permissions
and uncheck the permission named 'View user information' for the concerned roles, then save.
This does not affect users when they are on their own account page.
I did the following test, created two new users (4 and 5 in my case) :
- user
4
can accessuser/4
page but has "Access denied" foruser/5
page. - user
5
can accessuser/5
page but has "Access denied" foruser/4
page. - both users
4
and5
have "Access denied" foruser/1
page.
Go to admin path : /admin/people/permissions
and uncheck the permission named 'View user information' for the concerned roles, then save.
This does not affect users when they are on their own account page.
I did the following test, created two new users (4 and 5 in my case) :
- user
4
can accessuser/4
page but has "Access denied" foruser/5
page. - user
5
can accessuser/5
page but has "Access denied" foruser/4
page. - both users
4
and5
have "Access denied" foruser/1
page.
edited yesterday
EricLavault
34617
34617
answered yesterday
izus
448213
448213
@EricLavault I need to display user information on some parts of my site. I'm just trying to ban the account page.
– user90437
23 hours ago
@user90437 Yes, and ..? You asked a question, and this question got a very clear answer that received several upvotes from the community, meaning other people here including me would be totally satisfied with this answer. If there is anything that you don't understand, please elaborate. Otherwise, you should accept the answer, putting the green flag for other people wondering how to allow users to only visit their own user page, why not ?
– EricLavault
19 hours ago
@EricLavault So I had to leave my original question
– user90437
18 hours ago
@user90437, I think so too this answers all of your question. If you want to display user information on other parts of your site you can build a View. Views doesn't check for permissions unless instructed to do so.
– 4k4
7 hours ago
add a comment |
@EricLavault I need to display user information on some parts of my site. I'm just trying to ban the account page.
– user90437
23 hours ago
@user90437 Yes, and ..? You asked a question, and this question got a very clear answer that received several upvotes from the community, meaning other people here including me would be totally satisfied with this answer. If there is anything that you don't understand, please elaborate. Otherwise, you should accept the answer, putting the green flag for other people wondering how to allow users to only visit their own user page, why not ?
– EricLavault
19 hours ago
@EricLavault So I had to leave my original question
– user90437
18 hours ago
@user90437, I think so too this answers all of your question. If you want to display user information on other parts of your site you can build a View. Views doesn't check for permissions unless instructed to do so.
– 4k4
7 hours ago
@EricLavault I need to display user information on some parts of my site. I'm just trying to ban the account page.
– user90437
23 hours ago
@EricLavault I need to display user information on some parts of my site. I'm just trying to ban the account page.
– user90437
23 hours ago
@user90437 Yes, and ..? You asked a question, and this question got a very clear answer that received several upvotes from the community, meaning other people here including me would be totally satisfied with this answer. If there is anything that you don't understand, please elaborate. Otherwise, you should accept the answer, putting the green flag for other people wondering how to allow users to only visit their own user page, why not ?
– EricLavault
19 hours ago
@user90437 Yes, and ..? You asked a question, and this question got a very clear answer that received several upvotes from the community, meaning other people here including me would be totally satisfied with this answer. If there is anything that you don't understand, please elaborate. Otherwise, you should accept the answer, putting the green flag for other people wondering how to allow users to only visit their own user page, why not ?
– EricLavault
19 hours ago
@EricLavault So I had to leave my original question
– user90437
18 hours ago
@EricLavault So I had to leave my original question
– user90437
18 hours ago
@user90437, I think so too this answers all of your question. If you want to display user information on other parts of your site you can build a View. Views doesn't check for permissions unless instructed to do so.
– 4k4
7 hours ago
@user90437, I think so too this answers all of your question. If you want to display user information on other parts of your site you can build a View. Views doesn't check for permissions unless instructed to do so.
– 4k4
7 hours ago
add a comment |
user90437 is a new contributor. Be nice, and check out our Code of Conduct.
user90437 is a new contributor. Be nice, and check out our Code of Conduct.
user90437 is a new contributor. Be nice, and check out our Code of Conduct.
user90437 is a new contributor. Be nice, and check out our Code of Conduct.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fdrupal.stackexchange.com%2fquestions%2f272668%2fwhen-visiting-user-id-how-to-allow-users-to-only-visit-their-own-user-page%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Welcome to Drupal Answers! We love to help you. What you are asking for, it has nothing to do with Twig or templates in the first place. So I reworded your question and removed the Twig template from it.
– leymannx
yesterday
1
Uncheck the permission that deals with viewing user profiles? That should solve it? Unless that affects the current user too.
– Kevin
yesterday