Fatal Error after Plugin creation
-
Hello,
i created a plugin and tried to activate it.
Unfortunatelly i get some Fatal Errors.
After research via google i found out, that i use some wp functions which are working in functions.php of theme but not in the plugin.I found out that it seems to be the problem, that this function are not initialised yet. But if i want to use some wp functions in my plugin what i have to do?
My code:
<?php defined( 'ABSPATH' ) or die( 'Error' ); /* Plugin Name: MyPlugin Description: This is my own Plugin */ function get_user_roles() { if( is_user_logged_in() ) { $user = wp_get_current_user(); $roles = ( array ) $user->roles; return $roles; // This returns an array // Use this to return a single value // return $roles[0]; } else { return array(); } } function print_a($value) { echo '<pre>'; print_r($value); echo '</pre>'; } $myuserid = get_current_user_id(); $myuserrole = get_user_roles($myuserid)[0]; $usermeta = get_user_meta($myuserid, 'ztgm_abo_cats');
Viewing 5 replies - 1 through 5 (of 5 total)
Viewing 5 replies - 1 through 5 (of 5 total)
- The topic ‘Fatal Error after Plugin creation’ is closed to new replies.