0

Notice: Undefined index: mtral_field_subscriber in /wp-content/plugins/redirect-after-login/redirect-after-login.php on line 54

Warning: Cannot modify header information - headers already sent by (output started at /wp-content/plugins/redirect-after-login/redirect-after-login.php:54) in wp-includes/pluggable.php on line 1219

I get the above error and the error occurs specifically after I login since I am using Redirect After Login plugin in wordpress

How can I debug and fix it ?

2 Answers 2

2

You can simply remove that plugin, and create that redirection youself.

You can use the login_redirect hook, add this into your theme's functions.php

function redirect_admin( $redirect_to, $request, $user ){

    //is there a user to check?

    if ( isset( $user->roles ) && is_array( $user->roles ) ) {

        //check for admins
        if ( in_array( 'administrator', $user->roles ) ) {

            $redirect_to = get_site_url().'/a-page/'; // Your redirect URL
        }
    }

    return $redirect_to;
}

add_filter( 'login_redirect', 'redirect_admin', 10, 3 );
0
-1

How can I debug and fix it ?

The issue is straightforward and the error identifies the specific file and line number that it's occurring on, but since this is a plugin it's something that the plugin author has to fix. You need to contact them and tell them to fix it or find another plugin.

That being said, a PHP notice like this is a minor issue, not something that should appear in production in front of the public. To prevent errors appearing to the public, in your wp-config.php file set WP_DEBUG_DISPLAY to false:

define('WP_DEBUG_DISPLAY', false);

But to keep a log of any errors, set WP_DEBUG_LOG to true:

define('WP_DEBUG_LOG', true);
7
  • 2
    :( hiding errors do not fix them. All security bugs start with unintended execution flow that this kind of errors provide Commented Aug 20, 2018 at 15:59
  • They're not being hidden, they're being logged and should be actioned, but in production errors shouldn't be shown to end users. Commented Aug 20, 2018 at 16:05
  • 1
    yes, but that is in no way an answer to the question of debugging and fixing it, it is an answer to "how do I avoid the error being displayed" Commented Aug 20, 2018 at 16:06
  • 1
    and all errors are not "minor". The severity is just something to indicate that the code will continue to execute, it is not indicates that the cause or other possible impacts are minor Commented Aug 20, 2018 at 16:07
  • My first paragraph is the answer: No debugging needs to be done because the issue is obvious from the error message, and the fix needs to be done by the plugin's developer. The only 'fix' they can implement without them is to deactivate the plugin, which was suggested. And no, not all errors a minor, but they still shouldn't be public in production. Commented Aug 20, 2018 at 16:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.