Inside my active theme there is a user.php which serves this kind of url http://mysite.com/user/username. Inside user.php I echo a script tag with the following content
$.ajax({ url: "' . get_theme_root_uri() . '/fray/userslogan.php",
data: {"id": ' . $profile['id'] . ', "slogan": el.innerHTML},
type: "post",
success: function(status) { alert(status); }
});
I created a file userslogan.php and added it at the same level as user.php. Inside this file now all I want to do is
<?php
update_user_meta( $_POST['id'], 'slogan', $_POST['slogan'] );
echo 1;
?>
but I get errors that functions that I call are undefined. So if I include some file that defines the update_user_meta function, then I will get another similar error and so on. What is the right way of executing code like this?