• Resolved katering

    (@katering)


    Hi folks

    I managed to setup Ultimate Forum but now I do have a question regarding the login-page. Whenever I try to login I see the default WordPress login page. How do I replace that with the Ultimate Forum login? I checked the link in the native login-page and it seems to be the correct ID.

    Thanks a lot for your help
    kate

    The page I need help with: [log in to see the link]

Viewing 1 replies (of 1 total)
  • Hi @katering,

    There’s a couple of ways of doing this. My preferred approach is to use a function (you’d place this in your functions.php file for your theme) like the below

    add_action('init','set_redirect');
    
    function set_redirect(){
     global $pagenow;
     if( 'wp-login.php' == $pagenow ) {
      wp_redirect('YOUR CUSTOM PAGE URL');
      exit();
     }
    }

    You’d replace “YOUR CUSTOM PAGE URL” with the actual URL you want to use.

    Or, you can use this one

    // Hook the appropriate WordPress action
    add_action('init', 'prevent_wp_login');
    
    function prevent_wp_login() {
        // WP tracks the current page - global the variable to access it
        global $pagenow;
        // Check if a $_GET['action'] is set, and if so, load it into $action variable
        $action = (isset($_GET['action'])) ? $_GET['action'] : '';
        // Check if we're on the login page, and ensure the action is not 'logout'
        if( $pagenow == 'wp-login.php' && ( ! $action || ( $action && ! in_array($action, array('logout', 'lostpassword', 'rp', 'resetpass', 'register'))))) {
            // Load the home page url
            $page = get_bloginfo('url');
            // Redirect to the home page
            wp_redirect($page);
            // Stop execution to prevent the page loading for any reason
            exit();
        }
    }

    In this case, I am redirecting all requests to the homepage, but this can be any URL of your choosing.

    Finally, you can disable wp-login.php if you are using UM to control the login and register process – you can still login and register without it.

Viewing 1 replies (of 1 total)
  • The topic ‘Replace WP-login’ is closed to new replies.