Hi Davit, I hope you're well.
In order to achieve this, you'll need to persist the
anonymousId and/or the userId for the newly registered/logged in user. The PHP SDK will not automatically persist these identifiers for you as its a server-sided SDK as appose to something like the JavaScript SDK which does persist these identifiers.
By persisting these identifiers you will have your first rough form of
identity resolution, from there it will be up to the destinations where you're sending the data to, to actually stitch those identifiers and essentially handle the identity stitching. Needless to say I am oversimplifying the solution but that's because it's a very complicated and time consuming task to create that whole process of identity resolution & stitching.
The good news is that RudderStack makes this complicated process fairly simple through their
Profiles feature. Take a look at the link there and I'm sure you'll find something you might be interested in.