Page 1 of 1

Modifying username when submitting posts

Posted: Fri Nov 29, 2019 1:27 pm
by Appaulling
Hi,
I am trying to find a way to change the username when submitting posts, so that you can be logged in as "A" but write posts as "Anonymous1234". However, so far all my attempts to do so have not worked out. Subscribing to "submit_post_data" and setting the user_id does not work, because later phpBB simply overrides this with $user->data['user_id']. Trying to change the SQL also does not work, because as far as I can see there is no event that allows overriding the last_poster_name that is also stored in the topics table. So as far as I can see the best way to do this would be to override $user->data['user_id'] for the submit_post function. Is there a way to do this?

Re: Modifying username when submitting posts

Posted: Fri Nov 29, 2019 1:55 pm
by EA117
For what it's worth, one extension I can think of which does this is the "Contact Admin" extension. It has the ability to post the contact forms as messages in a forum, using a designated user account you've specified in the extension configuration. So they would effectively be in a session where the actual user is Guest/anonymous, but posting a message as though they were the user account that had been specified. While waiting for other programmatic advice, you might want to look at their code to see what ideas you glean from that.

Re: Modifying username when submitting posts

Posted: Fri Nov 29, 2019 2:56 pm
by mrgoldy
Well, this is not what phpBB was designed for, so yes it is not that easily doable.
There are ways of doing it, but they are susceptible to bugs and errors.
This will require overloading the $user and $auth objects.

You can have a look at the "Linked Accounts" extension, that does something similar.

But once again, tread carefully!