2

does anyone know what I am doing wrong here? I am trying to create profile pages for each user, but when I click the submit button, it doesn't take me to the user's page.

This is my form code:

<form method="get" accept-charset="UTF-8" class="form"    action="/profile/{{ user }}"> <input type="hidden" name="action" value="users/login">

<input id="loginName" type="text" name="loginName" placeholder="username"
    value="{{ craft.session.rememberedUsername }}">

<input id="password" type="password" name="password" placeholder="secret password">

<input type="submit" value="Login" class="login_enter">

<label class="remember">
    <input type="checkbox" name="rememberMe" value="1" checked>
    Remember me
</label>


{% if errorMessage is defined %}
    <p class="remember">{{ errorMessage }}</p>
{% endif %}

I have a profile folder and an _profile template. I also added a custom route in the admin panel with the following URI

    profile/*

And a link to the template

    profile/_profile

The profile index file looks like this:

{% set users = craft.users %}
{% for user in users %}
<a href="/profile/{{ user }}">{{ user }}</a>
{% endfor %}

And the _profile file looks like this

{% extends "_account_register_layout" %}
{% set title = "account" %}
{% set user = craft.users.username( craft.request.segment(2) ).first() %}
2

Try setting the action and redirect as hidden inputs, see below:

<form method="post">
    <input type="hidden" name="action" value="users/saveUser">
    <input type="hidden" name="redirect" value="/profile/{{ currentUser.username }}">
  • I accidentally deleted my stack exchange profile - stupid, I know. Just wanted to say thanks @Brad. It worked :) – Remco Apr 23 '17 at 15:18
  • Glad to hear that! – Brad Apr 23 '17 at 15:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy