Every time I use wp_get_current_user() my plugin breaks


I have been trying to make a sign-out plugin that allows users to sign out from military training activities that they should be at. After they fill out a form explaining why they are not going to be at an activity, they submit it, and it puts all the data into a mysql database. I am trying to save the user’s id to their other data so we can tell who is signing out, but everything I have tried breaks the plugin, and gives me the white screen of death.

Thanks for your help. Here is my code to get the users id:

function f2user() {
// Get the current user's info 
$current_user = wp_get_current_user(); 

if ( !($current_user instanceof WP_User) ) 

return $current_user->ID;

$usersid = f2user();
$activity = $_POST['activity'];
$reason = $_POST['reason'];
$explanation = $_POST['explanation'];
, , , FriedRyan 7 years 2016-07-12T23:02:07-05:00 0 Answers 109 views 0

Leave an answer