Hello S2Member community,
I’m trying to add a feature to my S2Member login form. Since my courses aren’t paid through the platform, I’ve set the default registration to Level 0 (which I call “Vale”) as the standard signup level. After registration, I manually edit the user’s profile to assign the appropriate level, allowing students to access courses right from signup.
The issue is that I’m using the free registration code, but by default, S2Member doesn’t send a welcome email when a student signs up at this level (especially with custom passwords enabled). I want them to receive one.
Additionally, to prevent incorrect emails or intentional signups with invalid emails, I’d like to add email validation (e.g., a confirmation link to activate the account and block login until confirmed). I’m using Elementor Pro, S2Member Pro, and Code Snippets.
How can I fix this? Any hooks, custom code, or settings recommendations would be great!
What I’ve Tried So Far:
I’ve attempted to use custom PHP snippets via Code Snippets to override the default behavior, but they didn’t work as expected (no email sent, or validation not triggering properly). Here’s a summary:
Custom Welcome Email Snippet: Hooked into ws_plugin__s2member_after_user_registration to send a personalized email for Level 0 registrations. It checks the level and uses wp_mail to send a custom message with placeholders like username and password reset link. However, it doesn’t trigger or send the email.
Example code structure:
Php
Copiar
add_action(‘ws_plugin__s2member_after_user_registration’, ‘enviar_email_boas_vindas_personalizado’, 10, 1);
function enviar_email_boas_vindas_personalizado($vars) {
if ($vars[‘level’] == 0) {
// Get user data
$user = get_user_by(‘id’, $vars[‘user_id’]);
// Build custom message with placeholders
$message = “Olá, {$user->display_name} !\n…”; // Full custom content here
wp_mail($user->user_email, ‘Bem-vindo à Escalada Poliglota!’, $message);
}
}
Email Validation Snippet: Tried to mark accounts as “pending” with user meta, send a confirmation email with a token link, process the confirmation on init, and block login with wp_authenticate_user until confirmed. This also targets Level 0, but the hooks don’t seem to fire, and users can still log in without confirmation.
Example code structure:
Php
Copiar
add_action(‘ws_plugin__s2member_during_add_new_user’, ‘marcar_usuario_pendente’);
function marcar_usuario_pendente($vars) {
if ($vars[‘level’] == 0) {
update_user_meta($vars[‘user_id’], ‘conta_pendente’, true);
}
}
// Additional functions for sending confirmation, processing, and blocking login…
These snippets run “everywhere” in Code Snippets, but no luck. Maybe I’m missing a specific S2Member hook or there’s a conflict with custom passwords?
Additional Details:
Shortcode used for the login form:
[s2Member-Login
title=“Acesse Seus Cursos”
login_redirect=“https://escaladapoliglota.com/sala-poliglota”
signup_url="%%automatic%%"
show_summary_if_logged_in=“1”
profile_title=“Bem-vindo de volta!”
my_account_url=“https://escaladapoliglota.com/perfil/”
my_profile_url=“https://escaladapoliglota.com/perfil/”
/]
Shortcode used for new student registration:
[s2Member-Pro-Stripe-Form register=“1” level=“0” ccaps="" desc=“Signup now, it’s Free!” custom=“escaladapoliglota.com” tp=“0” tt=“D” captcha=“clean” success=“https://escaladapoliglota.com/cursos/” /]
If you need any other technical information (like S2Member version, error logs, or full snippet code) to suggest adjustments, just ask.
Thanks in advance!