Component Development - Modifying the OSSNUser class.

Michieal ~ Coder ~ Posted in Component Development 4 years ago

I was reading through the documentation, and it said not to modify the base classes, as it will be over written in the future. (Of which, I understand that.)
However, I want to add data to the actual user. I want to add things like access level, which groups that they moderate, etc.

I tried copying the OSSNUser.php class file to a classes directory in my component, and then registering the class in the com file (like how OSSNGroups does it) but it didn't work.
Is there a way to do this, or hook it, or something? I need to be able to update the data points at key times like user creation, deletion, etc.

Thank you!

Replies
us Michieal ~ Coder ~ Replied 4 years ago

Also, I need to know how to hook the user's creation, so that I can add

$user->data->extended_atrrib_1 

at the point of user creation, so that when it's checked later it doesn't return an error.

And, how do I check that? do I use

$user->extended_atrrib_1 

or

$user->data->extended_atrrib_1 

?

Sorry for breaking it up so much, I came back to check to see if I had a response, and found that the system had garbled my message.

us Michieal ~ Coder ~ Replied 4 years ago

Also, I need to know how to hook the user's creation, so that I can add $user->data->extendedatrrib1 at that point, so later, when it's ($user->data->extendedatrrib1) checked, it doesn't return an error.

us Michieal ~ Coder ~ Replied 4 years ago

@Arsalan
Uhm... because I didn't know how to do that? :D

Thank you,
-M.

Indonesian Arsalan Shah Replied 4 years ago

Not sure why you wanna update the user class as you can add more stuff to user by following as example

$user = ossn_user_by_guid(1); //replace with id
$user->data->extra_attribute_a = 123;
$user->data->extra_attribute_b = 234;
$user->save();

.

Premium Version

Due to the many requests in the past for additonal features and components we have decided to develope a premium version. Features like Hashtags, Videos, Polls, Events, Stories, Link Preview, etc included in it.

$199 (Life Time)
Learn More

Other Questions