Advertisement
Guest User

Example of WP Login and Register form on same page template

a guest
Jul 15th, 2013
235
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 6.83 KB | None | 0 0
  1. <?php
  2.  
  3. get_header();
  4.  
  5. get_template_part('includes/breadcrumbs');
  6.  
  7. if (get_option('magnificent_integration_single_top') <> '' && get_option('magnificent_integrate_singletop_enable') == 'on') echo(get_option('magnificent_integration_single_top'));
  8. ?>
  9.         <div id="entries" class="fullwidth">
  10.         <div class="entry post entry-full">
  11.             <div class="border">
  12.                 <div class="bottom">
  13.                     <div class="entry-content clearfix">
  14.                         <div id="page-content-div">
  15.                             <?php the_content(); ?>
  16.                         </div>
  17. <?php if( 'yes' === $new_user ) { ?>
  18.                         <div id="logon" class="logon-register clearfix">
  19.                             <div class="border alignleft" style="margin: 18px; width: 45%;">
  20.                                 <div class="title">
  21.                                     <h4>
  22.                                         Sign On To Your Account
  23.                                     </h4>
  24.                                     <hr />
  25.                                 </div>
  26.                                 <div>
  27.                                     <form name="loginform" id="loginform" action="<?php echo wp_login_url(get_permalink()) ?>" method="post">
  28.                                         <div class="alignleft" style="width: 100%;">
  29.                                             <input type="hidden" name="redirect_to" value="<?php echo get_permalink() ?>" />
  30.                                             <input type="hidden" name="testcookie" value="1" />
  31.                                             <label for="user_login">Username<br />
  32.                                             <input type="text" name="log" id="user_login_signon" class="input login_input" value="" />
  33.                                             </label> <br /> <label for="user_pass">Password<br />
  34.                                             <input type="password" name="pwd" id="user_pass" class="input login_input" value="" />
  35.                                             </label>
  36.                                             <ul class="sav-nav">
  37.                                                 <li class="sav-nav post" style="font-size: 14px;"><a id="AcceptLogin" href="#">Sign-In</a></li>
  38.                                             </ul>
  39.                                         </div>
  40.                                         <div class="alignleft"  style="width: 100%;">
  41.                                             <hr />  
  42.                                             <label for="rememberme">
  43.                                             <input name="rememberme" type="checkbox" id="rememberme" value="forever" tabindex="90" />
  44.                                             Remember Me</label>
  45.                                         </div>
  46.                                     </form>
  47.                                 </div>
  48.                             </div>
  49.                             <div class="border alignleft" style="margin: 18px; width: 45%;">
  50.                                 <div class="title">
  51.                                     <h4>
  52.                                         Account Services
  53.                                     </h4>
  54.                                     <hr />
  55.                                 </div>
  56.                                 <div class="title">
  57.                                     <h5><a href="#register-form" class="fancybox" id="show-register">Create A New Account</a></h5>
  58.                                     <h5><a href="<?php echo wp_lostpassword_url( get_permalink()) ?>" title="Password Lost and Found">Recover Your Password</a></h5>
  59.                                     <h5><a href="<?php echo wp_logout_url( home_url() ); ?>" title="Logout">Log Out</a></h5>
  60.                                 </div>
  61.                             </div>
  62.                         </div>
  63. <?php } else { ?>
  64.                 <!-- a lot of code for the custom user profile form -->
  65. <?php } ?>
  66.                     <div class="fancybox-hidden" style="display:none">
  67.                         <div id="register-form">
  68.                             <div class="title">
  69.                                 <h3>Create A New Account</h3>
  70.                             </div>
  71.                             <div>
  72.                                 <form name="registerform" id="registerform" action="<?php echo wp_login_url() ?>?action=register&redirect_to=<?php echo get_permalink() ?>" method="post">
  73.                                     <input type="hidden" name="redirect_to" value="<?php echo get_permalink() ?>" />
  74.                                     <div class="alignleft" style="width: 100%;">
  75.                                         <label for="user_name">User Name<br />
  76.                                         <input type="text" name="user_login" id="user_login_register" class="input reg_input" value="your account name" /></label><small>This is the "account" name; keep it short</small>
  77.                                         <br />
  78.                                         <label for="user_email">Email Address<br />
  79.                                         <input type="text" name="user_email" id="user_email" class="input reg_input" value="your email address" /></label><small>This must be a working address</small>
  80.                                         <br />
  81.                                         <ul class="sav-nav">
  82.                                             <li class="sav-nav post" style="font-size: 18px;"><a id="AcceptRegister" href="#" >Register</a></li>
  83.                                             <li class="sav-nav post" style="font-size: 18px;" ><a id="CancelRegister" href="#" >Cancel</a>&nbsp;|</li>
  84.                                         </ul>
  85.                                     </div>
  86.                                     <div class="alignleft"  style="width: 100%;">
  87.                                         <hr />  
  88.                                         <p class="statement">A password will be e-mailed to you.</p>
  89.                                         <p class="statement">Please check your "junkmail" and "spam" mail box if you don't see it in your inbox.</p>
  90.                                     </div>
  91.                                 </form>
  92.                             </div>
  93.                         </div>
  94.                     </div>
  95.     <!-- end .entry-content -->
  96.                 </div>
  97.     <!-- end .bottom -->
  98.             </div>
  99.     <!-- end .border -->
  100.         </div>
  101.     <!-- end .entry -->
  102.     </div> <!-- end .container -->
  103.     <div class="clear">
  104.     </div>
  105. <?php if (get_option('magnificent_integration_single_bottom') <> '' && get_option('magnificent_integrate_singlebottom_enable') == 'on') echo(get_option('magnificent_integration_single_bottom')); ?>
  106. <?php if (get_option('magnificent_show_pagescomments') == 'on') comments_template('', true); ?>
  107. </div>
  108. <!-- end #entries -->
  109. <script type="text/javascript">
  110. // <![CDATA[
  111. jQuery(document).ready(function(){
  112.  
  113.     jQuery('#CancelRegister').click(function(e){
  114.         parent.jQuery.fancybox.close();
  115.         return false;
  116.     });
  117.    
  118.     jQuery('#AcceptRegister').click(function(e){
  119.         jQuery('#registerform').submit();
  120.         return false;
  121.     });
  122.        
  123.     jQuery(".reg_input").keyup(function(event){
  124.         if(event.keyCode == 13){
  125.             jQuery("#AcceptRegister").click();
  126.         }
  127.         if(event.keyCode == 27){
  128.             jQuery("#CancelRegister").click();
  129.         }
  130.     });
  131.    
  132. <?php if( 'yes' === $new_user ) { ?>
  133.     jQuery('#CancelLogin').click(function(e){
  134.         parent.jQuery.fancybox.close();
  135.         return false;
  136.     });
  137.    
  138.     jQuery('#AcceptLogin').click(function(e){
  139.         jQuery('#loginform').submit();
  140.         return false;
  141.     });
  142.    
  143.     jQuery(".login_input").keyup(function(event){
  144.         if(event.keyCode == 13){
  145.             jQuery("#AcceptLogin").click();
  146.         }
  147.         if(event.keyCode == 27){
  148.             jQuery("#CancelLogin").click();
  149.         }
  150.     });
  151.    
  152.     jQuery('#user_login').focus();
  153. <?php } else { ?>
  154.     jQuery('#stateSelector').val('<?php echo $meta[3] ?>');
  155.    
  156.     jQuery("#tabs li").click(function() {
  157.         //  First remove class "active" from currently active tab
  158.         jQuery("#tabs li").removeClass('active');
  159.  
  160.         //  Now add class "active" to the selected/clicked tab
  161.         jQuery(this).addClass("active");
  162.  
  163.         //  Hide all tab content
  164.         jQuery(".tab_content").hide();
  165.  
  166.         //  Here we get the href value of the selected tab
  167.         var selected_tab = jQuery(this).find("a").attr("href");
  168.  
  169.         //  Show the selected tab content
  170.         jQuery(selected_tab).fadeIn();
  171.  
  172.         //  At the end, we add return false so that the click on the link is not executed
  173.         return false;
  174.     });
  175.    
  176.     jQuery('#AcceptRegistration').click(function(){
  177.         state_code = jQuery('#stateSelector').val();
  178.         jQuery('#state').val(state_code);
  179.         jQuery('#profile').submit();
  180.         return false;
  181.     });
  182.    
  183.     jQuery('input').keyup(function(event) {
  184.         jQuery('.message').hide();
  185.     });
  186.        
  187. <?php if ( isset($_GET['updated']) ) { ?>
  188.     jQuery('#tab-2').trigger('click');
  189. <?php } else { ?>
  190.     jQuery('#tab-1').trigger('click');
  191. <?php } ?>
  192. <?php } ?>
  193. });
  194. // ]]>
  195. </script>
  196. <?php get_footer(); ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement