programmers_39
programmers_39

Reputation: 89

How to call WordPress function from other files

Hi All i am in word Press

I am successfully integrate WordPress membership plugin and all data of users is save in database. different users have different Levels

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

require_once("/wp-load.php");
$current_user = wp_get_current_user();

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

Upvotes: 0

Views: 1703

Answers (1)

Sandra
Sandra

Reputation: 418

Try this:

$parse_uri = explode( 'wp-content', $_SERVER['SCRIPT_FILENAME'] );

require_once( $parse_uri[0] . 'wp-load.php' );

This will give correct path of wp_load file.

Upvotes: 4

Related Questions