These classes are based on a (slightly) improved set of classes and functions that were originally built on CodeAcademy and that we have found extremely useful. They can serve as a basis for not only UserSpice or for your project as a whole. If you copy and paste this code, please get rid of the space before the opening php tag.
Once a user is logged in, you have access to $user. Most likely, you are going to want to access a piece of information about the logged in user.
If you do a var_dump of $user->data(), you are going to get something like this.
At this point, you can call a piece of data using something like this:
Which will echo out 13 to the page.
If you’re going to use this a lot, you can do something at the top of the page like:
$logged_in = $user->data();
From then on you can just call,
Of course, you might want to make things dynamic based on whether or not the user is logged in at all. You can write some pretty great if/else statements or cause redirects based on the logged in condition such as