Forums
-
- Forum
- Posts
-
- Installing BuddyPress
- 23,840
- How-to & Troubleshooting
- 129,871
- Creating & Extending
- 25,907
- Requests & Feedback
- 9,550
- Third Party Plugins
- 9,832
- Showcase
- 3,316
- Ideas
- 1,402
- Miscellaneous
- 9,179
-
Most probably the code you are using is trying to access logged in user’s data before init action. Since the current user is set on ‘set_current_user’ hook’ which is just before init, any function trying to access current user data should be called on or after init action.
Hope that helps.
Reference: https://codex.wordpress.org/Plugin_API/Action_Reference