[wp-trac] [WordPress Trac] #35340: PHP Fatal Error: Call to undefined method WP_Error::exists()
WordPress Trac
noreply at wordpress.org
Thu Jan 7 01:57:00 UTC 2016
#35340: PHP Fatal Error: Call to undefined method WP_Error::exists()
--------------------------+------------------------------
Reporter: crackhd | Owner:
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Users | Version: 4.4
Severity: minor | Resolution:
Keywords: | Focuses:
--------------------------+------------------------------
Changes (by crackhd):
* severity: normal => minor
Comment:
Error is caused in my site plugin, sorry for bad report.
here is code that causes this error:
{{{
// Password reset redirection
add_action('login_headerurl', 'site_checkamail_check');
function site_checkamail_check()
{
// Check if have submitted
$confirm = ( isset($_GET['checkemail'] ) ? $_GET['checkemail'] : '' );
if( $confirm )
{
wp_redirect(home_url('/login?msg=checkemail'));
exit;
}
}
/**
* Redirect user after successful login.
*/
function my_login_redirect( $redirect_to, $request, $user )
{
// Check if have an user instance...
global $user;
if (isset($user))
{
// Check for moderator access
if (user_can($user, 'delete_others_posts'))
{
// redirect them to admin console
return home_url('/wp-admin/');
}
else
{
// Others go to home page
echo "normal user!";
return home_url();
}
}
echo "no user!";
return $redirect_to;
}
add_filter( 'login_redirect', 'my_login_redirect', 999, 3 );
}}}
I am not sure, but it was working fine previosly, and i don't understand
why "WP_Error" appears in $user global.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/35340#comment:2>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list