Create users automatically and change record owner

This sub-forum is for discussing all topics related to AppGini Helper JavaScript Library, provided by bizzworxx as a third-party AppGini plugin.
Post Reply
balfons
Veteran Member
Posts: 91
Joined: 2018-10-22 15:27

Create users automatically and change record owner

Post by balfons » 2021-07-21 09:06

Good morning,

I'm starting a project and I have a couple of doubts/questions about automatic user creation and changing record owner. My scenario is as follows:

- A guest user creates a record
- She has the option of creating a new user. If so, I want to create a new user (belonging to a certain group, let's name it 'follow_group') and change the owner of the newly created record

I tried with a sql insert in the tablename.php tablename_anfer_insert() but then I found the function set_record_owner. The problem with the sql insert is that I can create the new user in the membership_users table but I can't change the record owner.

Then I tried the solution described in viewtopic.php?f=4&t=4262&p=16953&hilit= ... ner#p16953 but nothing happens.

Can anybody hel me?

Thanks is advance

User avatar
jsetzer
AppGini Super Hero
AppGini Super Hero
Posts: 1807
Joined: 2018-07-06 06:03
Location: Kiel, Germany
Contact:

Re: Create users automatically and change record owner

Post by jsetzer » 2021-07-21 11:30

Hi,

first of all, I don't think your question belongs here (in this sub-forum), because your request has nothing to do with AppGini Helper Javascript Library. So I guess you'd get more experts' attention when asking general questions in one of the general AppGini forums.

Anyway, if I remember right, the owner will be overwritten by AppGini core code AFTER the hook has been executed unless you return FALSE.

Search in TABLENAME_dml.php for function TABLENAME_insert. Almost at the end of that fn you will find set_record_owner call which will be executed if TABLENAME_after_insert not returns FALSE.

In other words: when changing the owner in after_insert hook and returning TRUE, AppGini will overwrite the owner by the currently logged in memberID. Try to return FALSE from after_insert hook.
Kind regards,
<js />

My AppGini Blog:
https://appgini.bizzworxx.de/blog

You can help us helping you:
Please always put code fragments inside [code]...[/code] blocks for better readability

AppGini 24.10 Revision 1579 + all AppGini Helper tools

balfons
Veteran Member
Posts: 91
Joined: 2018-10-22 15:27

Re: Create users automatically and change record owner

Post by balfons » 2021-07-27 09:06

thanks Jan, and sorry for the inconvenience.

User avatar
jsetzer
AppGini Super Hero
AppGini Super Hero
Posts: 1807
Joined: 2018-07-06 06:03
Location: Kiel, Germany
Contact:

Re: Create users automatically and change record owner

Post by jsetzer » 2021-07-27 18:03

No prob, does it work now?
Kind regards,
<js />

My AppGini Blog:
https://appgini.bizzworxx.de/blog

You can help us helping you:
Please always put code fragments inside [code]...[/code] blocks for better readability

AppGini 24.10 Revision 1579 + all AppGini Helper tools

Post Reply