This forum has moved to a new location and is in read-only mode. Please visit talk.octobercms.com to access the new location.

munikarmanish
munikarmanish

I extended the User plugin by creating a separate Profile plugin (as recommended in the video tutorial). I followed it all and I can do everything that's shown in video. But now, a Profile is only created if a User is added or edited from the backend. I'm trying to display the Profile information after a user logs in, but I get an error.

I want to generate a Profile for an existing User (if it doesn't already have) immediately when he logs in. How can I do that?

Note that I don't want to touch the User plugin code.

Thanks in advance. :)

Last updated

daftspunky
daftspunky

A couple of ways

// Listen for after login event
Event::listen('backend.user.login', function($user) {
    // Create profile here
});

Or you can go deeper

// For all users
User::extend(function($user) {
    // After any user is fetched from the database
    $user->bindEvent('model.afterFetch', function() use ($user) {
        // Create profile for user
    });
});

1-2 of 2

You cannot edit posts or make replies: the forum has moved to talk.octobercms.com.