Ivan Gretsky Posted February 4, 2016 Posted February 4, 2016 I am using this wonderfull feature to create users with different templates and under different parents. Now I need to do it via API. Looking at the source code it seems like I can easilly create a user with alternative template. But is there a way to specify parent page?Certainly I can get still just create the users as pages like here, but that does not read as well and does not allow me to use addRole().
Ivan Gretsky Posted February 4, 2016 Author Posted February 4, 2016 ...ok just do it as with a regular Page $u = new User(); $u->template = "custom-user-template"; $u->parent = "custom-user-parent"; $u->save(); Sometimes you need to spoil your forum karma to get your head working as it should) 5
LostKobrakai Posted February 4, 2016 Posted February 4, 2016 Sometimes you need to spoil your forum karma to get your head working as it should) So true!
Martijn Geerts Posted February 4, 2016 Posted February 4, 2016 Sometimes you need to spoil your forum karma to get your head working as it should)My opinion: "it doesn't spoil your carma. You just show you're not afraid to be 'ignorant' in the open. That is a state where you show the others: 'I want to learn' and that is quite a strong one. --- The reason it just works is just that User is extending Page, so User is a page with a few extra methods and stuff. 2
Ivan Gretsky Posted February 4, 2016 Author Posted February 4, 2016 The reason it just works is just that User is extending Page, so User is a page with a few extra methods and stuff. Yep, that's clear to me now. Thanks to PW I know some OOP. But I was confused by User constructor accepting template as parameter, but not accepting parent. 1
Martijn Geerts Posted February 4, 2016 Posted February 4, 2016 Same here before PW had not a real understanding of OOP. It was more like: If I do this, i might expect this. Let's trial and error that one out. 2
elabx Posted February 7, 2016 Posted February 7, 2016 Yep, that's clear to me now. Thanks to PW I know some OOP. But I was confused by User constructor accepting template as parameter, but not accepting parent. I didn't even know PHP could actually look like that. First time I was like, "what the heck with all those arrows?".
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now