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




















  • 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

















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




















  • 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













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















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















share|improve this question













share|improve this question




share|improve this question








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














  • 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










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













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
});


}
});














 

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

















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















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




















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




















 

draft saved


draft discarded



















































 


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

If I really need a card on my start hand, how many mulligans make sense? [duplicate]

Alcedinidae

Can an atomic nucleus contain both particles and antiparticles? [duplicate]