• Hi all,

    I’ve implemented a custom login button for my wordpress woocommerce site, with a little help from a freelancer.

    It’s all currently working with the exception that if someone puts in the wrong password or username etc the error is still processed through the wp-login.php page, I don’t want this I want it to be processed in the login dropdown in my header.php. Here is the code I have currently which was produced by the freelance, I suspect it is wrong, can anyone help?

    <fieldset id="signin_menu">
      	<?php if (is_user_logged_in()) {
    
    			$user = get_user_by('id', get_current_user_id());
    
    			if ( $logged_in_title ) echo $before_title . sprintf( $logged_in_title, ucwords($user->display_name) ) . $after_title;
    
    			do_action('woocommerce_login_widget_logged_in_before_links');
    
    			$links = apply_filters( 'woocommerce_login_widget_logged_in_links', array(
    				__('My account', 'woocommerce') 	=> get_permalink(woocommerce_get_page_id('myaccount')),
    				__('Change my password', 'woocommerce') => get_permalink(woocommerce_get_page_id('change_password')),
    				__('Logout', 'woocommerce')		=> wp_logout_url(home_url())
    			));
    
    			if (sizeof($links>0)) :
    
    				echo '<div style="padding-left:10px">';
    
    				foreach ($links as $name => $link) :
    					echo '<a href="'.$link.'">'.$name.'</a>';
    				endforeach;
    
    				echo '</div>';
    			endif;	
    
    			do_action('woocommerce_login_widget_logged_in_after_links');
    
    		} else {
    
    			if ( $logged_out_title ) echo $before_title . $logged_out_title . $after_title;
    
    			do_action('woocommerce_login_widget_logged_out_before_form');
    
    			if ( is_wp_error($user_verify) )
    			{
    				echo "<span style='color:#FF0000'>Invalid username or password. Please try again!</span>";
    				exit();
    			} 			
    
    			// Get redirect URL
    			$redirect_to = apply_filters( 'woocommerce_login_widget_redirect', get_permalink(woocommerce_get_page_id('myaccount')) );
    			} ?>
    <?php if (!is_user_logged_in()) { ?>
    	<form name="loginform" id="login" action="<?php echo get_settings(‘siteurl’); ?>/wp-login.php" method="post">
          <label for="username">Username</label>
          <input value="" title="username" tabindex="4" type="text" name="log" id="user_login" class="input" size="20">
          </p>
          <p>
            <label for="password">Password</label>
            <input value="" title="password" tabindex="5" type="password"  name="pwd" id="user_pass" class="input">
          </p>
          <p class="remember">
            <input id="signin_submit" name="wp-submit" value="Sign in" tabindex="6" type="submit" >
            <input id="rememberme" name="remember_me" value="forever" tabindex="7" type="checkbox">
            <label for="remember">Remember me</label>
          </p>
          <p class="forgot"> <a>" id=forgot_username_link
    title="If you don't remember your password you can retrive it here" >Forgot your password?</a> </p>
        </form>
    <?php } ?>
    
      </fieldset>

    [Moderator Note: Please post code or markup snippets between backticks or use the code button. Or better still – use the pastebin. As it stands, your code has now been permanently damaged/corrupted by the forum’s parser.]

The topic ‘Custom login dropdown’ is closed to new replies.