Advertisement
Guest User

Untitled

a guest
Jul 18th, 2016
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 8.02 KB | None | 0 0
  1. <?php
  2. /**
  3.  * Template name: Register Page
  4.  *
  5.  * Learn more: http://codex.wordpress.org/Template_Hierarchy
  6.  *
  7.  * @package WordPress
  8.  * @subpackage FlatAds
  9.  * @since FlatAds 1.0
  10.  */
  11.  
  12. if ( is_user_logged_in() ) {
  13.  
  14.     global $redux_demo;
  15.     $profile = $redux_demo['profile'];
  16.     wp_redirect( $profile ); exit;
  17.  
  18. }
  19.  
  20. global $user_ID, $user_identity, $user_level, $registerSuccess;
  21.  
  22. $registerSuccess = "";
  23.  
  24.  
  25. if (!$user_ID) {
  26.  
  27.     if($_POST)
  28.  
  29.     {
  30.  
  31.         $message = "<?php _e( 'Registration successful.', 'agrg' ); ?>";
  32.  
  33.         $username = $wpdb->escape($_POST['username']);
  34.  
  35.         $email = $wpdb->escape($_POST['email']);
  36.  
  37.         $password = $wpdb->escape($_POST['pwd']);
  38.  
  39.         $confirm_password = $wpdb->escape($_POST['confirm']);
  40.  
  41.         $registerSuccess = 1;
  42.  
  43.  
  44.  
  45.         if(empty($username)) {
  46.             $message = "<?php _e( 'User name should not be empty.', 'agrg' ); ?>";
  47.             $registerSuccess = 0;
  48.         }
  49.  
  50.        
  51.  
  52.         if(isset($email)) {
  53.  
  54.             if (preg_match("/^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$/", $email)){
  55.  
  56.                 wp_update_user( array ('ID' => $user_ID, 'user_email' => $email) ) ;
  57.  
  58.             }
  59.  
  60.             else { $message = "<?php _e( 'Please enter a valid email.', 'agrg' ); ?>"; }
  61.  
  62.             $registerSuccess = 0;
  63.  
  64.         }
  65.  
  66.         if($password) {
  67.  
  68.             if (strlen($password) < 5 || strlen($password) > 15) {
  69.  
  70.                 $message = "<?php _e( 'Password must be 5 to 15 characters in length.', 'agrg' ); ?>";
  71.  
  72.                 $registerSuccess = 0;
  73.  
  74.                 }
  75.  
  76.             //elseif( $password == $confirm_password ) {
  77.  
  78.             elseif(isset($password) && $password != $confirm_password) {
  79.  
  80.                 $message = "<?php _e( 'Password Mismatch', 'agrg' ); ?>";
  81.  
  82.                 $registerSuccess = 0;
  83.  
  84.             } elseif ( isset($password) && !empty($password) ) {
  85.  
  86.                 $update = wp_set_password( $password, $user_ID );
  87.  
  88.                 $message = "<?php _e( 'Registration successful.', 'agrg' ); ?>";
  89.  
  90.                 $registerSuccess = 1;
  91.  
  92.             }
  93.  
  94.         }
  95.  
  96.         $status = wp_create_user( $username, $password, $email );
  97.         if ( is_wp_error($status) ) {
  98.             $registerSuccess = 0;
  99.             $message = "<?php _e( 'Username or E-mail already exists. Please try another one.', 'agrg' ); ?>";
  100.         } else {
  101.             $from = get_option('admin_email');
  102.             $headers = 'From: '.$from . "\r\n";
  103.             $subject = "Registration successful";
  104.             $msg = "Registration successful \n Your login details \n Username: $username\n Password: $password";
  105.             wp_mail( $email, $subject, $msg, $headers );
  106.  
  107.             $registerSuccess = 1;
  108.         }
  109.  
  110.  
  111.         if($registerSuccess == 1) {
  112.  
  113.             $login_data = array();
  114.             $login_data['user_login'] = $username;
  115.             $login_data['user_password'] = $password;
  116.             $user_verify = wp_signon( $login_data, false );
  117.  
  118.             global $redux_demo;
  119.             $profile = $redux_demo['profile'];
  120.             wp_redirect( $profile ); exit;
  121.  
  122.         }
  123.  
  124.                
  125.  
  126.     }
  127.  
  128. }
  129.  
  130. get_header(); ?>
  131.  
  132.     <section id="ad-page-title" class="add-new-post-header" >
  133.        
  134.         <div class="container">
  135.  
  136.             <div class="span9 first">
  137.                 <h2><?php the_title(); ?></h2>
  138.  
  139.             </div>
  140.  
  141.         </div>
  142.  
  143.     </section>
  144.  
  145.     <section class="ads-main-page">
  146.  
  147.         <div class="container">
  148.  
  149.             <div class="span9 first">
  150.  
  151.                 <?php                  
  152.                     if(get_option('users_can_register')) { //Check whether user registration is enabled by the administrator
  153.                 ?>
  154.  
  155.                 <div id="edit-profile" class="ad-detail-content">
  156.  
  157.                     <div class="one_half first">
  158.                    
  159.                         <form class="form-item" action="" id="primaryPostForm" method="POST" enctype="multipart/form-data">
  160.  
  161.                                 <?php if($_POST) {
  162.  
  163.                                     global $redux_demo;
  164.                                     $login = $redux_demo['login'];
  165.  
  166.                                     echo "<div id='result' style='margin-bottom: 30px;'><div class='message'><h3>".$message." ";
  167.  
  168.                                     if($registerSuccess == 1) {
  169.                                         echo "<a href='".$login."'>Login</a>.";
  170.                                     }
  171.  
  172.                                     echo "</h3></div></div>";
  173.  
  174.                                 } ?>
  175.  
  176.                                     <?php if($registerSuccess == 1) { } else { ?>
  177.  
  178.                                     <fieldset class="input-title">
  179.  
  180.                                         <label for="edit-title" class="control-label"><?php _e('Username:', 'agrg') ?></label>
  181.                                         <input type="text" name="username" class="text" value="" />
  182.  
  183.                                     </fieldset>
  184.  
  185.                                     <fieldset class="input-title">
  186.  
  187.                                         <label for="edit-title" class="control-label"><?php _e('E-mail:', 'agrg') ?></label>
  188.                                         <input type="text" name="email" class="text" value="" />
  189.  
  190.                                     </fieldset>
  191.  
  192.                                     <fieldset class="input-title">
  193.  
  194.                                         <label for="edit-title" class="control-label"><?php _e('Password:', 'agrg') ?></label>
  195.                                         <input type="password" name="pwd" class="text" />
  196.  
  197.                                     </fieldset>
  198.  
  199.                                     <fieldset class="input-title">
  200.  
  201.                                         <label for="edit-title" class="control-label"><?php _e('Retype password:', 'agrg') ?></label>
  202.                                         <input type="password" name="confirm" class="text" />
  203.  
  204.                                     </fieldset>
  205.  
  206.                                     <div class="hr-line"></div>
  207.  
  208.                                     <div class="publish-ad-button">
  209.                                         <input type="hidden" name="submit" value="Register" id="submit" />
  210.                                         <button class="btn form-submit" id="edit-submit" name="op" value="Publish Ad" type="submit"><?php _e('Submit', 'agrg') ?></button>
  211.                                     </div>
  212.  
  213.                                 <?php } ?>
  214.  
  215.                         </form>
  216.  
  217.                     </div>
  218.  
  219.                     <div class="one_half social-links">
  220.  
  221.                         <div class="register-page-title">
  222.  
  223.                             <?php _e( 'Social account login', 'agrg' ); ?>
  224.  
  225.                         </div>
  226.  
  227.                         <?php
  228.                         /**
  229.                          * Detect plugin. For use on Front End only.
  230.                          */
  231.                         include_once( ABSPATH . 'wp-admin/includes/plugin.php' );
  232.  
  233.                         // check for plugin using plugin name
  234.                         if ( is_plugin_active( "nextend-facebook-connect/nextend-facebook-connect.php" ) ) {
  235.                           //plugin is activated
  236.                        
  237.                         ?>
  238.  
  239.                         <fieldset class="input-full-width">
  240.  
  241.                             <a class="register-social-button-facebook" href="<?php echo get_site_url(); ?>/wp-login.php?loginFacebook=1" onclick="window.location = '<?php echo get_site_url(); ?>/wp-login.php?loginFacebook=1&redirect='+window.location.href; return false;"><i class="fa fa-facebook-square"></i> Facebook</a>
  242.                            
  243.                         </fieldset>
  244.  
  245.                         <?php } ?>
  246.  
  247.                         <?php
  248.                         /**
  249.                          * Detect plugin. For use on Front End only.
  250.                          */
  251.                         include_once( ABSPATH . 'wp-admin/includes/plugin.php' );
  252.  
  253.                         // check for plugin using plugin name
  254.                         if ( is_plugin_active( "nextend-twitter-connect/nextend-twitter-connect.php" ) ) {
  255.                           //plugin is activated
  256.                        
  257.                         ?>
  258.  
  259.                         <fieldset class="input-full-width">
  260.  
  261.                             <a class="register-social-button-twitter" href="<?php echo get_site_url(); ?>/wp-login.php?loginTwitter=1" onclick="window.location = '<?php echo get_site_url(); ?>/wp-login.php?loginTwitter=1&redirect='+window.location.href; return false;"><i class="fa fa-twitter-square"></i> Twitter</a>
  262.  
  263.                         </fieldset>
  264.  
  265.                         <?php } ?>
  266.  
  267.                         <?php
  268.                         /**
  269.                          * Detect plugin. For use on Front End only.
  270.                          */
  271.                         include_once( ABSPATH . 'wp-admin/includes/plugin.php' );
  272.  
  273.                         // check for plugin using plugin name
  274.                         if ( is_plugin_active( "nextend-google-connect/nextend-google-connect.php" ) ) {
  275.                           //plugin is activated
  276.                        
  277.                         ?>
  278.  
  279.                         <fieldset class="input-full-width">
  280.  
  281.                             <a class="register-social-button-google" href="<?php echo get_site_url(); ?>/wp-login.php?loginGoogle=1" onclick="window.location = '<?php echo get_site_url(); ?>/wp-login.php?loginGoogle=1&redirect='+window.location.href; return false;"><i class="fa fa-google-plus-square"></i> Google</a>
  282.  
  283.                         </fieldset>
  284.  
  285.                         <?php } ?>
  286.  
  287.                         <div class="publish-ad-button">
  288.  
  289.                             <?php
  290.  
  291.                                 global $redux_demo;
  292.                                 $login = $redux_demo['login'];
  293.                                 $reset = $redux_demo['reset'];
  294.  
  295.                             ?>
  296.                            
  297.                             <p><a href="<?php echo $login; ?>">Login</a></p>
  298.  
  299.                         </div>
  300.  
  301.                     </div>
  302.  
  303.                 </div>
  304.  
  305.                 <?php }
  306.                        
  307.                     else echo "<span class='registration-closed'><?php _e( 'Registration is currently disabled. Please try again later.', 'agrg' ); ?></span>";
  308.  
  309.                 ?>
  310.  
  311.             </div>
  312.  
  313.             <div class="span3">
  314.  
  315.                 <?php get_sidebar('pages'); ?>
  316.  
  317.             </div>
  318.  
  319.         </div>
  320.  
  321.     </section>
  322.  
  323. <?php get_footer(); ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement