2

I'm new to craft, in fact I haven't built a site with it yet, but am looking forward to getting my teeth into this interesting and seemingly very flexible CMS.

I am about to embark on a medium sized website build and have a question that is kind of a deal breaker for choosing the CMS. My question is:

Can I create users that have their own profile page, who can only edit their own page and do nothing else? This won't be a public registration, but administered internally, however they must be able to maintain a profile containing images, text and predetermined layouts that they can choose between.

Thanks guys!


Brad, Thanks so much for your response.

Regarding the URL - could it be configured to be something like mydomain.com/members/membername instead of passing a url option?

1 Answer 1

0

Absolutely.

From the template side you'd do something like this to ensure they're editing their own page:

{# assuming the URL structure for the profile page looks something like http://mydomain.com/users?id=5 %}

{% set editUserId = craft.request.getParam('id') %}

{% if editUserId and currentUser.id == editUserId %}
    You're in!
{$ else %}
    {% exit 403 %}
{% endif %}

Where currentUser is a global variable that's a UserModel object.

4
  • Brad, Thanks so much for your response. Regarding the URL - could it be configured to be something like mydomain.com/members/membername instead of passing a url option? Commented Aug 23, 2015 at 8:28
  • Sure, but that's still passing it through the URL. You're just using their username instead of their ID.
    – Brad Bell
    Commented Aug 23, 2015 at 16:20
  • Finally, can I allow one user enter the CP and only edit their own profile there, or does it have to be administered by them on the front end? Commented Aug 24, 2015 at 8:52
  • 1
    I can say, that coming to the end of this project, the user admin / front end templating has been nothing short of incredible. With such a helpful community both here on stackexchange and slack, I feel that I can achieve almost anything with craft! Commented Dec 22, 2015 at 17:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.