ob_start() redirects my wp-admin
-
Hi,
I’m currently working on a custom login.
I found this online and try to work with it.I ran into a little problem that said: Headers allready sent…
I found the ob_start(); function:function app_output_buffer() { ob_start(); } add_action('init', 'app_output_buffer');
This does do the trick. My users can now login to the website.
However, if I try to login to my wp-admin the page redirects me to the login page on the website.Here is my code on the login page:
<?php if($_POST) { global $wpdb; //We shall SQL escape all inputs $username = esc_sql($_REQUEST['username']); $password = esc_sql($_REQUEST['password']); $login_data = array(); $login_data['user_login'] = $username; $login_data['user_password'] = $password; $user_verify = wp_signon( $login_data, false ); if ( is_wp_error($user_verify) ) { echo "<span class=\"error\">Invalid username or password. Please try again!</span>"; } else { echo "<script type=\"text/javascript\">window.location='". get_bloginfo('url') . "/home-extranet'</script>"; exit(); } } ?> <form id="login" name="form" action="<?php echo home_url(); ?>/login/" method="post"> <input id="username" type="text" placeholder="Username" name="username"> <input id="password" type="password" placeholder="Password" name="password"> <input id="submit" type="submit" name="submit" value="Submit"> </form>
Here is the page that it redirects to if login is approved:
<?php if(!is_user_logged_in()) { wp_redirect(home_url() . '/login' ); }else{ ?> <h1><?php the_title(); ?></h1> <?php }?>
Once again if the usere logs in via the website there is no problem, but if I try to login to my wp-admin it redirects to de login on my website.
Any ideas???? I’m kinda stuck…
M.
- The topic ‘ob_start() redirects my wp-admin’ is closed to new replies.