I would like to fetch the current logged In user data in a custom PHP file in my wordpress website, Here is the code I use, but it seems that it does not function. I wish someone helps me with this wordpress problem.
The theme I use is Astra child theme. It is a popular theme. The file I customize is /api/advance.php
Is it necessary to include any specific file path like user.php
or wp-header.php
to perform the action?
The problem can be fixed if you add the following code at the beginning HP file.
require_once(rtrim($_SERVER[‘DOCUMENT_ROOT’], ‘/’) . ‘/wp-load.php’);