I know one way of doing this. It might not be the most optimal but it works really well.
First make a scoreboard that count's all players in the game.
scoreboard objectives add PlayerCount dummy
Now make a second scoreboard to check if they logged in or not
scoreboard objectives add LoginTP dummy
Add the fake player past to 'PlayerCount'
scoreboard players add past PlayerCount 0
Now count the number of players and put that number into a score
execute store result score new PlayerCount run execute if entity @a
execute store result score new PlayerCount
tells the code to put the number into the fake layer 'new' in the 'PlayerCount' scoreboard
run execute if entity @a
count the number of players
This puts the number of players currently in the game into the scoreboard new
Now add all players to the 'LoginTP' scoreboard
scoreboard players add @a LoginTP 0
Now activate a tp command every time the number of players changes
execute unless score new PlayerCount = past PlayerCount run tp @a[scores={LoginTP=0}] ~ ~ ~
execute unless score new PlayerCount = past PlayerCount
checks if the past amount of players and 'new' amount of players are different
run tp @a[scores={LoginTP=0}] ~ ~ ~
if the scores are different this command runs
@a[scores={LoginTP=0}]
makes sure that the only ones with a score of 0 for 'LoginTP get teleported
Now you have to reset LoginTp every time the number of players changes
First delete the score whenever the player count changes
execute unless score new PlayerCount = past PlayerCount run scoreboard objectives remove LoginTP
And afterward, add the scoreboard back in again
scoreboard objectives add LoginTP dummy
And set all players in the world's score to 1
scoreboard players set @a LoginTP 1
Finally fix the PlayerCount
execute as @s run scoreboard players operation new PlayerCount = past PlayerCount
I highly recommend putting all these commands inside a single chain of repeating command blocks.
It would even be better if this is in a data pack.
Be sure these commands are always repeating and in order.