Every time I use wp_get_current_user() my plugin breaks

You can get current user ID easily using get_current_user_id(). $usersid = get_current_user_id(); $activity = $_POST[‘activity’]; $reason = $_POST[‘reason’]; $explanation = $_POST[‘explanation’]; For your function f2user() you can change your code to this: $current_user = wp_get_current_user(); return $current_user->ID; According to wp_get_current_user() doc, if no user is signed in, $current_user->ID would return 0.

WP Plugin: Print javascript in header

To only insert code into the header section in the admin area on single plugin pages you need to alter your add_action()function. add_action(‘admin_head-pageof_thisplugin/thisplugin’, ‘thisplugin_adminhead’); function thisplugin_adminhead() { // here goes your content echo ‘<script>’ .’/* … */’ .'</script>’; } where pageof_thisplugin/thispluginis the hook slug that returns out of the function that creates your page like … Read more