chrisull
Forum Replies Created
-
Forum: Plugins
In reply to: Including pluggable.php within a pluginRich, can you explain a bit about using the init hook or share some documentation? Many thanks.
Forum: Plugins
In reply to: [Post From Site] [Plugin: Post From Site] Fatal error: undefined functionCristiano, I don’t think you can get the user role. A better way would probably be to check if the user can perform a certain task according to their role’s capabilities.
Use
if current_user_can( 'capability_name' )and use this list of capabilities:Forum: Plugins
In reply to: [Post From Site] [Plugin: Post From Site] Fatal error: undefined functionHi there,
In short, the plugin is trying to look and see what level the logged-in user is. It’ll find that information in capabilities.php but it needs to use a function to do that (that function is wp_get_current_user().
Plugin code fires in WordPress before this function is defined, so, your plugin breaks upon not knowing what wp_get_current_user() is.
A workaround is to define that function within the plugin. You can do this by including pluggable.php, the file where these kinds of functions are.
So insert this line near the top of your plugin:
include_once(ABSPATH . 'wp-includes/pluggable.php');Forum: Fixing WordPress
In reply to: Admin: byline to another authorOkay never mind—looks like there has to be more than one user besides the admin.