CodeIgniter Forums
Need support on Shield - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: CodeIgniter 4 (https://forum.codeigniter.com/forumdisplay.php?fid=28)
+--- Forum: CodeIgniter 4 Support (https://forum.codeigniter.com/forumdisplay.php?fid=30)
+--- Thread: Need support on Shield (/showthread.php?tid=89343)



Need support on Shield - chakycool - 02-07-2024

Hi All,

I want create a profile section using the Shield library. Created a new table that can hold profile data. Now I just want to add the newly created member ID to link between the user table and the profile table automatically when the registration take place. Any idea how I can run a function to update this new table with out modifying Shield's core files using shield base registration flow?

thank you in advance.


RE: Need support on Shield - InsiteFX - 02-07-2024

You should be able to use the Auth Helper and get the user orĀ users ID.

Then use that as your promary key for your profile table.

PHP Code:
// get the current user
auth()->user();

// get the current user's id
auth()->id();
// or
user_id();

// get the User Provider (UserModel by default)
auth()->getProvider(); 



RE: Need support on Shield - chakycool - 02-08-2024

Thanks InsiteFx but I was looking for a method to chain a new function right after member creation happens from core shield function with out editing the core files. I hope that's clear.


RE: Need support on Shield - kenjis - 02-08-2024

Customize User Provider:
https://shield.codeigniter.com/customization/user_provider/
https://github.com/codeigniter4/shield/blob/develop/src/Models/UserModel.php
and add a model event for it.
https://codeigniter.com/user_guide/models/model.html#model-events