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
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
1
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
2 days ago
1
Uncheck the permission that deals with viewing user profiles? That should solve it? Unless that affects the current user too.
– Kevin
2 days ago
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
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
edited 2 days ago
leymannx
6,48142457
6,48142457
asked 2 days ago
user90437
1
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
2 days ago
1
Uncheck the permission that deals with viewing user profiles? That should solve it? Unless that affects the current user too.
– Kevin
2 days ago
add a comment |
1
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
2 days ago
1
Uncheck the permission that deals with viewing user profiles? That should solve it? Unless that affects the current user too.
– Kevin
2 days ago
1
1
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
2 days ago
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
2 days ago
1
1
Uncheck the permission that deals with viewing user profiles? That should solve it? Unless that affects the current user too.
– Kevin
2 days ago
Uncheck the permission that deals with viewing user profiles? That should solve it? Unless that affects the current user too.
– Kevin
2 days ago
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
yesterday
@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
yesterday
@EricLavault So I had to leave my original question
– user90437
yesterday
@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
yesterday
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
yesterday
@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
yesterday
@EricLavault So I had to leave my original question
– user90437
yesterday
@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
yesterday
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
yesterday
@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
yesterday
@EricLavault So I had to leave my original question
– user90437
yesterday
@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
yesterday
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 2 days ago
EricLavault
34617
34617
answered 2 days ago
izus
478213
478213
@EricLavault I need to display user information on some parts of my site. I'm just trying to ban the account page.
– user90437
yesterday
@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
yesterday
@EricLavault So I had to leave my original question
– user90437
yesterday
@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
yesterday
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
yesterday
@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
yesterday
@EricLavault So I had to leave my original question
– user90437
yesterday
@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
yesterday
@EricLavault I need to display user information on some parts of my site. I'm just trying to ban the account page.
– user90437
yesterday
@EricLavault I need to display user information on some parts of my site. I'm just trying to ban the account page.
– user90437
yesterday
@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
yesterday
@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
yesterday
@EricLavault So I had to leave my original question
– user90437
yesterday
@EricLavault So I had to leave my original question
– user90437
yesterday
@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
yesterday
@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
yesterday
add a comment |
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
1
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
2 days ago
1
Uncheck the permission that deals with viewing user profiles? That should solve it? Unless that affects the current user too.
– Kevin
2 days ago