I was thinking of making something like this which I'm describing below step by step. You may call it as a pseudocode.
on the start of the game a request will be sent via ajax to a php page to check if the user is logged in or not on my website. Note: I have a wordpress website. If not logged in he/she we'll just set a variable to false in our project. If logged in we'll store the username in a text variable and show something like "welcome "X" bla bla..."
In the end of each game on my website I want to have submit highscore button. So, when somebody clicks on that it'll check if the login variable status is true or false. If true then we'll post the username and the highscore to a php page which will post the score to the database. If the variable is false the user will be prompted to login with fields or submit as guest. I'm not quite familiar with mysql and php and struggling with scripts . Can somebody help? Thanks in advance.