Hi All i am in word Press

I have successfully integrated WordPress membership plugin and all data of users is saved in database. Different users have different levels.

My major task is to disable some website button according to user levels. so i try to Get user id in report.php using

$current_user = wp_get_current_user();

But it gives internal 500 error my directry structure is /myproject/wp-content/themes/fount/myfolder/report.php

  • where do you put your file? and also rember to check if your user is logged in with: is_user_logged_in() – Mederic Jan 17 '18 at 9:29
  • @Mederic my files are in themes folders – programmers_39 Jan 17 '18 at 9:31
  • If your files are in the themes folders, then require_once("/wp-load.php"); is incorrect. Use the correct path. – Otto Jan 17 '18 at 9:49
  • @Otto wp-load.php is my myproject folder which is root folder of our PROJECT – programmers_39 Jan 17 '18 at 9:54
  • 2
    it's not recommanded to use a direct acces to a PHP file. use instead AJAX (codex.wordpress.org/AJAX_in_Plugins) or REST (developer.wordpress.org/rest-api) – mmm Jan 17 '18 at 10:15

Let's say that wp-load is in the folder /myproject/ of your /myproject/wp-content/themes/fount/myfolder/ tree.

From /myfolder/ you would access it with "../../../../wp-load.php".

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.