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
1












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.










share|improve this question









New contributor




user90437 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.




















  • 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

















up vote
0
down vote

favorite
1












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.










share|improve this question









New contributor




user90437 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.




















  • 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













up vote
0
down vote

favorite
1









up vote
0
down vote

favorite
1






1





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.










share|improve this question









New contributor




user90437 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











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






share|improve this question









New contributor




user90437 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











share|improve this question









New contributor




user90437 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









share|improve this question




share|improve this question








edited yesterday









leymannx

6,46142457




6,46142457






New contributor




user90437 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









asked yesterday









user90437

42




42




New contributor




user90437 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.





New contributor





user90437 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.






user90437 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.












  • 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






  • 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










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 access user/4 page but has "Access denied" for user/5 page.

  • user 5 can access user/5 page but has "Access denied" for user/4 page.

  • both users 4 and 5 have "Access denied" for user/1 page.






share|improve this answer























  • @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













Your Answer








StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "220"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});






user90437 is a new contributor. Be nice, and check out our Code of Conduct.










 

draft saved


draft discarded


















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

























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 access user/4 page but has "Access denied" for user/5 page.

  • user 5 can access user/5 page but has "Access denied" for user/4 page.

  • both users 4 and 5 have "Access denied" for user/1 page.






share|improve this answer























  • @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

















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 access user/4 page but has "Access denied" for user/5 page.

  • user 5 can access user/5 page but has "Access denied" for user/4 page.

  • both users 4 and 5 have "Access denied" for user/1 page.






share|improve this answer























  • @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















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 access user/4 page but has "Access denied" for user/5 page.

  • user 5 can access user/5 page but has "Access denied" for user/4 page.

  • both users 4 and 5 have "Access denied" for user/1 page.






share|improve this answer














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 access user/4 page but has "Access denied" for user/5 page.

  • user 5 can access user/5 page but has "Access denied" for user/4 page.

  • both users 4 and 5 have "Access denied" for user/1 page.







share|improve this answer














share|improve this answer



share|improve this answer








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




















  • @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












user90437 is a new contributor. Be nice, and check out our Code of Conduct.










 

draft saved


draft discarded


















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.















 


draft saved


draft discarded














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





















































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







Popular posts from this blog

Costa Masnaga

Fotorealismo

Sidney Franklin