Hello,
I am new to Grav, and experiencing an odd problem. I am using the login plugin to allow users to register and access areas of the site based on their groups. Login works fine, but registering does not. When I hit the button to process the registration it redirects me to the front page ( which is where I want it to go ) but no new user is created.
Here is my register.md (Its default right now)
---
title: register
login_redirect_here: false
form:
fields:
fullname:
type: text
validate:
required: true
username:
type: text
validate:
required: true
message: PLUGIN_LOGIN.USERNAME_NOT_VALID
config-pattern@: system.username_regex
email:
type: email
validate:
required: true
message: PLUGIN_LOGIN.EMAIL_VALIDATION_MESSAGE
password1:
type: password
label: Enter a password
validate:
required: true
message: PLUGIN_LOGIN.PASSWORD_VALIDATION_MESSAGE
config-pattern@: system.pwd_regex
password2:
type: password
label: Enter the password again
validate:
required: true
message: PLUGIN_LOGIN.PASSWORD_VALIDATION_MESSAGE
config-pattern@: system.pwd_regex
buttons:
-
type: submit
value: Submit
-
type: reset
value: Reset
process:
register_user: true
message: "Thanks for registering..."
reset: true
---
register-form.html.twig
{% set client_side_validation = form.client_side_validation is not null ? form.client_side_validation : config.plugins.form.client_side_validation|default(true) %}
{% set inline_errors = form.inline_errors is not null ? form.inline_errors : config.plugins.form.inline_errors(false) %}
{% if page.template == "register" or show_register_form %}
{% set user = grav.user %}
{% if user.authenticated and user.authorized %}
<div class="form-box login-register-form-element">
<img class="form-box-decoration overflowing" src="{{ url("theme://images/social/landing/rocket.png", true) }}" alt="rocket">
<h2 class="form-box-title">{{ "PLUGIN_LOGIN.WELCOME"|t }} <strong>{{ user.fullname ?: user.username }}</h2>
<div class="form-row">
<div class="form-item">
<p class="lined-text">
<a class="button medium secondary wide" href="{{ uri.addNonce(base_url_relative ~ uri.path ~ "/task" ~ config.system.param_sep ~ "login.logout", "logout-form", "logout-nonce")|e }}">{{ "PLUGIN_LOGIN.BTN_LOGOUT"|t }}</a>
</p>
</div>
</div>
</div>
{% else %}
{{ content|raw }}
<div class="form-box login-register-form-element">
<img class="form-box-decoration" src="{{ url("theme://images/social/landing/rocket.png", true)}}" alt="rocket">
<h2 class="form-box-title">Create your Account!</h2>
<form name="register" action="/vgn/register" method="POST" id="register" class="form">
{% for field in form.fields %}
<div class="form-row">
<div class="form-item">
<div class="form-input">
{% set value = field.name == "username" ? username : "" %}
{% if field.type %}
{% include ["forms/fields/#{field.type}/#{field.type}.html.twig", "forms/fields/text/text.html.twig"] %}
{% endif %}
</div>
</div>
</div>
{% endfor %}
<div class="form-row">
<div class="form-item">
<div class="checkbox-wrap">
<input type="checkbox" id="register-newsletter" name="register_newsletter" checked>
<div class="checkbox-box">
<svg class="icon-cross">
<use xlink:href="#svg-cross"></use>
</svg>
</div>
<label for="register-newsletter">Send me news and updates via email</label>
</div>
</div>
</div>
<div class="form-row">
<div class="form-item">
<button class="{{ form_button_classes ?: 'button medium primary' }}" type="submit" ><i class="fa fa-sign-in"></i> Login to your account!</button>
<!-- <button class="button medium primary">Register Now!</button> -->
</div>
</div>
{{ nonce_field("register-form", "register-form-nonce")|raw }}
</form>
<p class="form-text">You"ll receive a confirmation email in your inbox with a link to activate your account. If you have any problems, <a href="#">contact us</a>!</p>
</div>
{% endif %}
{% endif %}
And register.html.twig
{% extends 'partials/social/landing.html.twig' %}
{% block content %}
{% include 'partials/messages.html.twig' %}
{% include 'partials/user/register-form.html.twig' %}
{% endblock %}
I believe the issue lies with the button that is submitting the registration form, I think im missing something super simple but keep going bye it.
Edit - With the help of @pamtbaau Ive gotten the formatting corrected!!! Thanks a lot mate!!