gottberg Posted November 26, 2018 Share Posted November 26, 2018 Hi, How do I create a page with another user than the user currently logged in as? Example. Im logged in as Simon (superuser) and would want to create a page in the name of Jesper(regular) user. I could of course set a custom field named userid in the form but is there another way? So if I would select Jesper from the dropdown of users it would add Jespers ID to the page. Am I on the wrong track? Couldn't find a answer by googling. Coming back to PW from a 6 year long break! :D Link to comment Share on other sites More sharing options...
Zeka Posted November 26, 2018 Share Posted November 26, 2018 On "Advanced" tab of a template settings page, you can enable setting ' Allow the 'created user' to be changed on pages?' Than you will be able to change 'create user' on settings tab on page edit page. 1 Link to comment Share on other sites More sharing options...
gottberg Posted November 26, 2018 Author Share Posted November 26, 2018 Thanks for the response! Sorry I didn't clarify I'm creating the pages using the API not by backend. Link to comment Share on other sites More sharing options...
kongondo Posted November 26, 2018 Share Posted November 26, 2018 Maybe: $page->createdUser = $jespersID; $page->of(false); $page->save(); Untested. http://processwire.com/api/ref/page/ Link to comment Share on other sites More sharing options...
BitPoet Posted November 26, 2018 Share Posted November 26, 2018 Allowing the user to be changed in the template is still necessary when you use the API, though you might get by if you temporarily set the flag. Then assign created_users_id the id of Jesper. // set up your new page, then... $page->template->allowChangeUser = true; $page->created_users_id = (int)$input->post->creatorid; // or however the input is named in the form $page->save(); 1 Link to comment Share on other sites More sharing options...
gottberg Posted November 26, 2018 Author Share Posted November 26, 2018 Thank you both! I will test both methods tomorrow ? Link to comment Share on other sites More sharing options...
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