如何从用户目录的根目录开始获取FTP路径?

I am using the WordPress method $wp_filesystem->put_contents() to write a file to the server. When I use an absolute path like the following no file will be put to that location:

/www/htdocs/w423fe4/wordpress/wp-content/plugins/file.zip

However when I change the path to start only after the user name (w423fe4) the file is indeed put to the server. So my question is is there any way to programmatically get the server path starting from the root of the user account in PHP? So basically what I like to get in the above case is this:

/wordpress/wp-content/plugins/file.zip

Or is this not possible because every server somehow has a different structure?

It would be "~/" at the beginning. "~" is a shortcut for the current user's home directory