Site icon Hip-Hop Website Design and Development

Customized Login Plugin Redirects to wp-login.php After Website Migration

I’m utilizing a customized login plugin I made for my website, it was working positive earlier than migration however now it redirects to the wp-login.php web page.

Previous Website -> http://prep.kevinmamaqi.com/ (nonetheless accessible and dealing)

New website -> https://www.buscopreparador.com

When I attempt to entry the brand new website I get redirected right here: https://www.buscopreparador.com/wp-login.php?redirect_to=httpspercent3Apercent2Fpercent2Fwww.buscopreparador.compercent2Fwp-adminpercent2F&reauth=1

That is my plugin code:

<?php
/*
Plugin Identify: Login BP
Plugin URI: https://www.kevinmamaqi.com
Description: Login para BuscoPreparador.com
Model: 1.0
Creator: Kevin Mamaqi
Creator URI: https://www.kevinmamaqi.com
License: GPL2
*/

/**
 * Provides Login_BP widget.
 */

// Activate output buffering
ob_start();


class BP_Login extends WP_Widget {

    static personal $login_registration_status;

    /**
     * Register widget with WordPress.
     */
    perform __construct() {
        guardian::__construct(
            'bp_login', // Base ID
            __( 'BP_Login', 'text_domain' ), // Identify
            array( 'description' => __( 'A tabbed login and registration widget for WordPress', 'text_domain' ), ) // Args
        );
    }

    /**
     * Returns the HTML for the login kind
     * @return string
     */
    static perform login_form() {
        $html = '<kind methodology="post" motion="' . esc_url( $_SERVER['REQUEST_URI'] ) . '">';
        $html .= '<div class="form-group"><enter kind="text" class="form-control" identify="login_username" id="login_username" placeholder="Nombre de Usuario"></div>';
        $html .= '<div class="form-group"><enter kind="password" class="form-control" identify="login_password" id="login_password" placeholder="Contraseña"></div>';
        $html .= '<div class="g-recaptcha" data-sitekey="6LefKhoTAAAAALBduf1bC_0TvopN2aUGU0X5rcos"></div>';
        $html .= '<div class="checkbox"><label><enter kind="checkbox" identify="remember_login" worth="true" checked="checked"> Recuerdame</label></div>';
        $html .= '<enter class="btn btn-primary btn-block" kind="submit" identify="login_submit" worth="Acceder" />';
        $html .= '<li function="separator" type="margin: 1.5em 0;" class="divider"></li>';
        $html .= '<p>¿Todavía no estas registrado?</p>';
        $html .= '<a category="btn btn-warning btn-block" href="' . wp_registration_url() . '">Únete</a>';
        $html .= '</kind>';

        return $html;

    }


    /**
     * Login registered customers
     */
    perform login_user() {
        if ( isset( $_POST['login_submit'] ) ) {

            $creds                  = array();
            $creds['user_login']    = esc_attr( $_POST['login_username'] );
            $creds['user_password'] = esc_attr( $_POST['login_password'] );
            $creds['remember']      = esc_attr( $_POST['remember_login'] );

            $login_user = wp_signon( $creds, false );

            if ( ! is_wp_error( $login_user ) ) {
                wp_redirect( home_url( 'wp-admin' ) );
            } elseif ( is_wp_error( $login_user ) ) {
                self::$login_registration_status = $login_user->get_error_message();
            }
        }
    }


    public perform widget( $args, $occasion ) { ?>

        <?php
        $title = apply_filters( 'widget_title', $occasion['title'] );

        echo $args['before_widget'];
        if ( ! empty( $title ) ) {
            echo $args['before_title'] . $title . $args['after_title'];
        } ?>

        <?php $this->login_user(); ?>

        <div class="login-reg-error"><?php echo self::$login_registration_status; ?></div>

        <?php echo self::login_form(); ?>

        <?php
        echo $args['after_widget'];
    }


    public perform kind( $occasion ) {
        if ( isset( $occasion['title'] ) ) {
            $title = $occasion['title'];
        } else {
            $title = __( 'Acceso BP', 'text_domain' );
        }
        ?>
        <p>
            <label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php _e( 'Title:' ); ?></label>
            <enter class="widefat" id="<?php echo $this->get_field_id( 'title' ); ?>"
                   identify="<?php echo $this->get_field_name( 'title' ); ?>" kind="text"
                   worth="<?php echo esc_attr( $title ); ?>">
        </p>
    <?php
    }

    public perform replace( $new_instance, $old_instance ) {
        $occasion          = array();
        $occasion['title'] = ( ! empty( $new_instance['title'] ) ) ? strip_tags( $new_instance['title'] ) : '';

        return $occasion;
    }

} // class BP_Login

// register Foo_Widget widget
perform register_bp_login() {
    register_widget( 'BP_login' );
}

add_action( 'widgets_init', 'register_bp_login' );

UPDATE
Altering wp_redirect( home_url( 'wp-admin' ) ); to wp_redirect( home_url() ); works. And makes me surprise if this perform to redirect primarily based on person roles has one thing to do, however unsure:

/**
 * Redirect person after profitable login.
 *
 * @param string $redirect_to URL to redirect to.
 * @param string $request URL the person is coming from.
 * @param object $person Logged person's information.
 * @return string
 */
perform my_login_redirect( $redirect_to, $request, $person ) {
  //is there a person to examine?
  if ( isset( $user->roles ) && is_array( $user->roles ) ) {
    //examine for admins
    if ( in_array( 'administrator', $user->roles ) ) {
      // redirect them to the default place
      return $redirect_to;

    } else {
      return home_url('mi-perfil');
    }
  } else {
    return $redirect_to;
  }
}

add_filter( 'login_redirect', 'my_login_redirect', 10, 3 );