Execute PHP code in Javascript onclick

In simple terms, window.location.href is javascript, and will run in the browser, but PHP runs on the server. In order to execute update_usermeta() you need to open a page with that block of code on it. The best way to do this from a click is to use AJAX (javascript) to visit the URL on which you have this code. Most likely you’ll need to create a new PHP file with your code in it and write some AJAX to visit the page.