Sidebar login widget with error print, returns an error
-
hi to the community,
i’m building a widget to login from the sidebar and print errors if any,
so everything is working fine except that when i login it returns an error:
Warning: Cannot modify header information – headers already sent…..the code of the widget:
<?php // Custom Login/Meta Widget function widget_artdev_meta() { ?> <?php global $user_ID, $user_identity, $user_level ?> <?php if ( $user_ID ) : ?> <div class="widget"> <h2>Control Panel</h2> <ul> <li>Identified as <strong><?php echo $user_identity ?></strong>. <ul> <?php if ( $user_level >= 10 ) : ?> <li><a href="<?php bloginfo('url') ?>/wp-admin">Dashboard</a></li> <?php endif // $user_level >= 10 ?> <?php if ( $user_level >= 1 ) : ?> <li><a href="<?php bloginfo('url') ?>/wp-admin/post-new.php">Write an article</a></li> <?php endif // $user_level >= 1 ?> <li><a href="<?php bloginfo('url') ?>/profile">Profile & personal options</a></li> <li><a href="<?php echo wp_logout_url( $_SERVER['REQUEST_URI'] ); ?>" title="Exit">Exit</a></li> </ul> </li> </ul> </div> <?php elseif ( get_option('users_can_register') ) : ?> <?php if ( 'POST' == $_SERVER['REQUEST_METHOD'] && !empty( $_POST['action'] ) && $_POST['action'] == 'log-in' ) : global $error; $login = wp_login( $_POST['log'], $_POST['pwd'] ); $login = wp_signon( array( 'user_login' => $_POST['log'], 'user_password' => $_POST['pwd'], 'remember' => $_POST['rememberme'] ), false ); endif; ?> <div class="widget"> <h2>Identification</h2> <?php if ( $error ) : ?> <p class="error"> <?php echo $error; ?> </p><!-- .error --> <?php endif; ?> <ul> <li> <form action="<?php the_permalink(); ?>" method="post"> <label for="log">User ID <input type="text" name="log" id="log" value="<?php echo wp_specialchars(stripslashes($user_login), 1) ?>" size="22" class="input_text_login alignright" /> </label> <label for="pwd">Password <input type="password" name="pwd" id="pwd" size="22" class="input_text_login alignright" /> </label> <input type="submit" name="submit" value="Login" class="button" style="margin-right:35px; width:70px;" /> <input name="rememberme" id="rememberme" type="checkbox" checked="checked" value="forever" /> Remember me <input type="hidden" name="action" value="log-in" /> <input type="hidden" name="redirect_to" value="<?php echo $_SERVER['REQUEST_URI']; ?>"/> </form> </li> <li><a href="<?php bloginfo('url') ?>/wp-login.php?action=lostpassword">Recover password</a></li> <li><a href="<?php bloginfo('url') ?>/register">Register</a></li> </ul> </div> <?php endif // get_option('users_can_register') ?> <?php } if ( function_exists('register_sidebar_widget') ) register_sidebar_widget(__('→ Login/Meta Widget','artdev'), 'widget_artdev_meta'); ?>
anyone out there can help?
i can’t understand where the problem is…!thanks a lot!
Philip
- The topic ‘Sidebar login widget with error print, returns an error’ is closed to new replies.