F
Filament2mo ago
mrvn

Customize VerifyEmail template and other login related emails

Overriding sendEmailVerificationNotification() in User model doesnt work as filament creates the notification directly instead of accessing the user. Could this be a bug? How to change the template and arguments then?
4 Replies
Povilas K
Povilas K2mo ago
Not sure about Verification email specifically, though, haven't tried, but maybe the same logic would work
mrvn
mrvn2mo ago
Thank you, I will check on that
putraprima
putraprima6d ago
i tried this logic but the first email send by filament always the default one but if we click the send email again button it will send the customized template any hints of how to fix it ? But i can confirm that the custom reset password email message works perfectly Oooh nevermind guys i got it : 1. Povilas tutorial is correct it works perfectly 2. To implement custom email message on registration you should also Extend the registration page in filament vendor 3. Create custom message for the first email when user register 4. Also create custom page for email verification prompt with custom email message so the user Here is some code snippet panel provider
return $panel
->default()
->id('user')
->path('user')
->login()
->registration(Register::class)
->emailVerification(EmailVerificationPrompt::class)
->passwordReset(RequestPasswordReset::class)
->sidebarWidth('16rem')
->colors([
'primary' => Color::Indigo,
])
return $panel
->default()
->id('user')
->path('user')
->login()
->registration(Register::class)
->emailVerification(EmailVerificationPrompt::class)
->passwordReset(RequestPasswordReset::class)
->sidebarWidth('16rem')
->colors([
'primary' => Color::Indigo,
])
Custom register page
<?php

namespace App\Filament\User\Pages\Auth;

use Filament\Pages\Auth\Register as AuthRegister;
use App\Notifications\VerifyEmailNotification;
use Exception;
use Filament\Facades\Filament;
use Filament\Pages\Auth\EmailVerification\EmailVerificationPrompt as BaseEmailVerificationPrompt;
use Illuminate\Contracts\Auth\MustVerifyEmail;
use Illuminate\Database\Eloquent\Model;

class Register extends AuthRegister
{
protected function sendEmailVerificationNotification(Model $user): void
{
if (!$user instanceof MustVerifyEmail) {
return;
}

if ($user->hasVerifiedEmail()) {
return;
}

if (!method_exists($user, 'notify')) {
$userClass = $user::class;

throw new Exception("Model [{$userClass}] does not have a [notify()] method.");
}

$notification = new VerifyEmailNotification(Filament::getVerifyEmailUrl($user));

$user->notify($notification);
}
}
<?php

namespace App\Filament\User\Pages\Auth;

use Filament\Pages\Auth\Register as AuthRegister;
use App\Notifications\VerifyEmailNotification;
use Exception;
use Filament\Facades\Filament;
use Filament\Pages\Auth\EmailVerification\EmailVerificationPrompt as BaseEmailVerificationPrompt;
use Illuminate\Contracts\Auth\MustVerifyEmail;
use Illuminate\Database\Eloquent\Model;

class Register extends AuthRegister
{
protected function sendEmailVerificationNotification(Model $user): void
{
if (!$user instanceof MustVerifyEmail) {
return;
}

if ($user->hasVerifiedEmail()) {
return;
}

if (!method_exists($user, 'notify')) {
$userClass = $user::class;

throw new Exception("Model [{$userClass}] does not have a [notify()] method.");
}

$notification = new VerifyEmailNotification(Filament::getVerifyEmailUrl($user));

$user->notify($notification);
}
}
Want results from more Discord servers?
Add your server
More Posts
Pass Data From Filament TextInput to Livewire ComponentI have added a livewire component on the create page of resource and wanted to pass a TextInput::makModify Export Action download URL linkMy app is deployed in a sub-folder https://example.com/my-app. How can i modify the download .csv orI try to seed using has function for relationship but does not create child record.I can propertyServices separately, it works. I wonder what I made wrong on using has in PropertySeedmultiple panels on single dashboard as tabs?Wondering how/if we can have multiple panels visible on a common dashboard for easy navigation! InForm does not revalidate after change valueI have set unique(ignoreRecord:true), when it to validate with red message the submit button is alsogetPageTableQuery() function on Simple Resource.Hi all, i have a question . currrently im using simple resource in my project. i wanted to use getPaHow modify rule for unique() when it must be unique if another field eg group are the same?I have a house that belongs to a villege. In the same villege house_no must be unique but in differeBootstrap for Landing Page?Hi i have existing project with bootstrap and i want to use filament. Is this advisable or possible.Spatie Media Library responsiveImages How to convert to webp?I tried to google for it but I did not found: how can I configure this plugin or the underlying LaraChanging registration formHi, I'd like to significantly change registration form, so in my case to remove "name" field, use em