Plugin – current user not set – user id 0
-
Hello,
i am not able to use the current user function inside of my plugin. the user object seems not to be initilized yet where the plugin is loaded.
Is it possible to force the user object init or is there a possibility like if not init then init?At my point the user id is static 0. (i wonder because some days ago it works).
I would be very thankful for hints what i made wrong.
code:
defined( 'ABSPATH' ) or die( 'No script kiddies please!' ); class MyPlugin { public $userid; protected $url; protected $path; protected $basename; public function __construct() { add_action( 'plugins_loaded', array( $this, 'plugin_setup' )); } function plugin_setup() { $this->url = plugin_dir_url(__FILE__); $this->path = plugin_dir_path(__FILE__); $this->basename = plugin_basename(__FILE__); $this->userid = get_current_user_id(); } } global $myplugin; $myplugin = new MyPlugin();
Viewing 9 replies - 1 through 9 (of 9 total)
Viewing 9 replies - 1 through 9 (of 9 total)
- The topic ‘Plugin – current user not set – user id 0’ is closed to new replies.