• Hi,
    I want to redirect my users after they submited the registration.
    Can you help me?
    Here I attach the code.
    Thanks

    iak3

    <?php
    /**
     * Template name: Login Page
     *
     * Learn more: https://codex.www.ads-software.com/Template_Hierarchy
     *
     * @package WordPress
     * @subpackage classiads
     * @since classiads 1.2.2
     */
     
    if ( is_user_logged_in() ) {
    
    	global $redux_demo;
    	$profile = $redux_demo['profile'];
    	wp_redirect( $profile ); exit;
    
    }
    
    global $user_ID, $username, $password, $remember;
    
    //We shall SQL escape all inputs
    $username = esc_sql(isset($_REQUEST['username']) ? $_REQUEST['username'] : '');
    $password = esc_sql(isset($_REQUEST['password']) ? $_REQUEST['password'] : '');
    $remember = esc_sql(isset($_REQUEST['rememberme']) ? $_REQUEST['rememberme'] : '');
    
    if($remember) $remember = "true";
    else $remember = "false";
    $login_data = array();
    $login_data['user_login'] = $username;
    $login_data['user_password'] = $password;
    $login_data['remember'] = $remember;
    $user_verify = wp_signon( $login_data, false );
    //wp_signon is a wordpress function which authenticates a user. It accepts user info parameters as an array.
    if($_POST['submit'] == 'Login'){
    	if ( is_wp_error($user_verify) ) {
    		$UserError = _e('Invalid username or password. Please try again!','agrg');
    	} else {
    
    		global $redux_demo;
    		$profile = $redux_demo['profile'];
    		wp_redirect( $profile ); exit;
    
    	}
    }
    global $redux_demo;
    $login = $redux_demo['login'];
    $rand1 = rand(0,9);
    $rand2 = rand(0,9);
    $rand_answer = $rand1 + $rand2;
    
    global $resetSuccess;
    
    if (!$user_ID) {
    
    	if($_POST['submit'] == 'Reset')
    
    	{
    
    		// First, make sure the email address is set
    		if ( isset( $_POST['email'] ) && ! empty( $_POST['email'] ) ) {
    
    		  	// Next, sanitize the data
    		  	$email_addr = trim( strip_tags( stripslashes( $_POST['email'] ) ) );
    
    		  	$user = get_user_by( 'email', $email_addr );
    		  	$user_ID = $user->ID;
    
    		  	if( !empty($user_ID)) {
    
    				$new_password = wp_generate_password( 12, false );
    
    				if ( isset($new_password) ) {
    
    					wp_set_password( $new_password, $user_ID );
    
    					$message = _e('Check your email for new password.','agrg');
    
    			      	$from = get_option('admin_email');
    					$headers = 'From: '.$from . "\r\n";
    					$subject = "Password reset!";
    					$msg = "Reset password.\nYour login details\nNew Password: $new_password";
    					wp_mail( $email_addr, $subject, $msg, $headers );
    
    					$resetSuccess = 1;
    
    				}
    
    		    } else {
    
    		      	$message = _e('There is no user available for this email.','agrg');
    
    		    } // end if/else
    
    		} else {
    			$message = _e('Email should not be empty.','agrg');
    		}
    
    	}
    
    }
    
     
    get_header(); ?>
    	<div class="ad-title">
    
            		<h2><?php the_title(); ?> </h2>
    	</div>
    
        <section class="ads-main-page">
    
        	<div class="container">
    			<div id="edit-profile" class="clearfix">
    
    <?php
    
     ?>
    
    					<div class="span4 log-forms">
    						<h3><?php _e( 'LOGIN', 'agrg' ); ?></h3>
    							<form class="form-item login-form" action="" id="primaryPostForm" method="POST" enctype="multipart/form-data">
    							<?php if($_GET['action'] == 'resetpass'){ ?>
    								<span style="margin-bottom: 10px; float: left;"><?php _e( 'Go to your inbox or spam/junk and get your password', 'agrg' ); ?></span>
    							<?php  } ?>
    							<?php if($_GET['action'] == 'register' && $_GET['success'] == '1'){ ?>
    								<span style="margin-bottom: 10px; float: left;"><?php _e( 'Go to your inbox or spam/junk and get your password', 'agrg' ); ?></span>
    							<?php  } ?>
    								<?php global $user_ID, $user_identity;
    								$current_user = wp_get_current_user(); ?>
    
    								<?php if(!empty($UserError)) { ?>
    									<span class='error' style='color: #d20000; margin-bottom: 20px; font-size: 14px; float: left;'><?php echo $UserError; ?></span><div class='clearfix'></div>
    								<?php } ?>
    
    										<input type="text" id="contactName" Placeholder="<?php _e( 'UserName', 'agrg' ); ?>" name="username" class="text input-textarea half" value="" />
    
    										<input type="password" id="password" Placeholder="<?php _e( 'Password', 'agrg' ); ?>" name="password" class="text input-textarea half" value="" />
    
    									<fieldset class="input-title">
    
    										<label for="edit-title" class="remember-me">
    											<input name="rememberme" type="checkbox" value="forever" style="float: left;"/><span style="margin-left: 10px; float: left;"><?php _e( 'Remember me', 'agrg' ); ?></span>
    
    											<?php
    
    												global $redux_demo;
    												$reset = $redux_demo['reset'];
    
    											?>
    
    										</label>
    
    									</fieldset>
    
    										<input type="hidden" id="submitbtn" name="submit" value="Login" />
    										<div class="clearfix"></div>
    
    											<button class="btn form-submit" id="edit-submit" name="op" value="<?php _e( 'Publish Ad', 'agrg' ); ?>" type="submit"><?php _e('LOGIN NOW', 'agrg') ?></button>
    
    							</form>
    							<div class="clearfix"></div>
    
    						<span class="sign-free"><?php _e('Sign Up for Free', 'agrg') ?></span>
    						<div class="register-page-title">
    
    							<h5><?php _e( 'Login via Social Media', 'agrg' ); ?></h5>
    
    						</div>
    						<div class="social-btn clearfix">
    							<?php
    							/**
    							 * Detect plugin. For use on Front End only.
    							 */
    							include_once( ABSPATH . 'wp-admin/includes/plugin.php' );
    
    							// check for plugin using plugin name
    							if ( is_plugin_active( "nextend-facebook-connect/nextend-facebook-connect.php" ) ) {
    							  //plugin is activated
    
    							?>
    
    									<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;"><?php _e('Login via Facebook', 'agrg') ?></a>
    
    							<?php } ?>
    
    							<?php
    							/**
    							 * Detect plugin. For use on Front End only.
    							 */
    							include_once( ABSPATH . 'wp-admin/includes/plugin.php' );
    
    							// check for plugin using plugin name
    							if ( is_plugin_active( "nextend-twitter-connect/nextend-twitter-connect.php" ) ) {
    							  //plugin is activated
    
    							?>
    
    									<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;"><?php _e('Login via Twitter', 'agrg') ?></a>
    
    							<?php } ?>
    
    							<?php
    							/**
    							 * Detect plugin. For use on Front End only.
    							 */
    							include_once( ABSPATH . 'wp-admin/includes/plugin.php' );
    
    							// check for plugin using plugin name
    							if ( is_plugin_active( "nextend-google-connect/nextend-google-connect.php" ) ) {
    							  //plugin is activated
    
    							?>
    
    									<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;"><?php _e('Login via Google', 'agrg') ?></a>
    
    							<?php } ?>
    
    						</div>
    
    					</div>
    
    									<?php
    					if(get_option('users_can_register')) { //Check whether user registration is enabled by the administrator
    				?>
    
    					<div class="span4 log-forms">
    					<h3><?php _e( 'REGISTER', 'agrg' ); ?></h3>
    						<form class="form-item login-form" action="" id="primaryPostForm" method="POST" enctype="multipart/form-data">
    
    								<?php
    
    											global $user_ID, $user_identity, $user_level, $registerSuccess;
    
    											$registerSuccess = "";
    
    											if (!$user_ID) {
    
    												if(isset($_POST['answer-hidden']))
    
    												{
    
    													if ( $_POST['answer'] == $_POST['answer-hidden'] ) {
    
    														$user_name = $wpdb->escape($_POST['username']);
    
    														$user_email = $wpdb->escape($_POST['email']);
    
    														$password = $wpdb->escape($_POST['pwd']);
    
    														$confirm_password = $wpdb->escape($_POST['confirm']);
    
    														$user_id = username_exists( $user_name );
    														if ( !$user_id and email_exists($user_email) == false and !empty($user_email) and !empty($user_name) and is_email($user_email)) {
    															$random_password = wp_generate_password( $length=12, $include_standard_special_chars=false );
    															$user_id = wp_create_user( $user_name, $random_password, $user_email );
    															$from = get_option('admin_email');
    															$headers = 'From: '.$from . "\r\n";
    															$subject = "Registration successful";
    				$msg = "Registration successful \n Your login details \n Username: $user_name \n Password: $random_password \n $login";
    															$headers2 = 'From: '.$user_email . "\r\n";
    															$subject2 = "New user register on your website.";
    				$msg2 = "New user register on your website \n User details are \n Username: $user_name \n Email: $user_email";
    															wp_mail( $user_email, $subject, $msg,  $headers);
    															wp_mail( $from, $subject2, $msg2,  $headers2);
    															echo '<span style="margin-left:-10px;margin-bottom: 10px; float: left;">'._e('Go to your inbox or spam/junk and get your password','agrg').'</span>';
    														}elseif(email_exists($user_email) == true){
    															echo '<span style="margin-left:-10px;margin-bottom: 10px; float: left;">'._e('This Email already exists','agrg').'</span>';
    														}
    														elseif(username_exists( $user_name ) == true){
    															echo '<span style="margin-left:-10px;margin-bottom: 10px; float: left;">'._e('This Username already exists','agrg').'</span>';
    														}elseif(empty($user_email)){
    															echo '<span style="margin-left:-10px;margin-bottom: 10px; float: left;">'._e('Email field is empty.','agrg').'</span>';
    														}elseif(!is_email($user_email)){
    															echo '<span style="margin-left:-10px;margin-bottom: 10px; float: left;">'._e('Please provide correct email.','agrg').'</span>';
    														}elseif(empty($user_name)){
    															echo '<span style="margin-left:-10px;margin-bottom: 10px; float: left;">'._e('Username field is empty.','agrg').'</span>';
    														}
    
    													}else{
    
    														echo '<span style="margin-left:-10px;margin-bottom: 10px; float: left;">'._e('Your answer is not correct. Try again!','agrg').'</span>';
    
    													}
    
    												}
    
    											}
    								?>
    
    									<input id="contactName" placeholder="<?php _e( 'User Name', 'agrg' ); ?>" type="text" name="username" class="text input-textarea half" value="" maxlength="30" />
    
    										<input id="email" placeholder="<?php _e( 'Email Address', 'agrg' ); ?>" type="text" name="email" class="text input-textarea half" value=""  maxlength="30" />
    									<br/>
    										<span class="pleaseanswer" style="line-height:52px;margin-left: 10px;margin-bottom: 10px; float: left;"><?php _e( 'Answer this please: ', 'agrg' ); echo $rand1.'+'.$rand2 ?></span>
    									<br/>
    									<input id="email" style="width:35% !important;float: right;margin-right: 0px !important;" placeholder="<?php _e( 'Your answer', 'agrg' ); ?>" type="text" name="answer" class="text input-textarea half" value=""  maxlength="30" />
    									<input type="hidden" name="answer-hidden" value="<?php echo $rand_answer; ?>" />
    
    									<br/>
    										<span style="margin-left: 10px;margin-bottom: 10px; float: left;"><?php _e( 'Password will be emailed to you.', 'agrg' ); ?></span>
    									<br/>
    									<br/>
    
    										<input type="hidden" name="submit" value="Register" id="submit" />
    										<div class="clearfix"></div>
    											<button class="btn form-submit" id="edit-submit" name="op" value="Publish Ad" type="submit"><?php _e('Submit', 'agrg') ?></button>
    
    						</form>
    
    						<div class="clearfix"></div>
    						<div class="register-page-title">
    
    							<h5><?php _e( 'Login via Social Media', 'agrg' ); ?></h5>
    
    						</div>
    						<div class="social-btn clearfix">
    							<?php
    							/**
    							 * Detect plugin. For use on Front End only.
    							 */
    							include_once( ABSPATH . 'wp-admin/includes/plugin.php' );
    
    							// check for plugin using plugin name
    							if ( is_plugin_active( "nextend-facebook-connect/nextend-facebook-connect.php" ) ) {
    							  //plugin is activated
    
    							?>
    
    									<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;"><?php _e( 'Login via Facebook', 'agrg' ); ?></a>
    
    							<?php } ?>
    
    							<?php
    							/**
    							 * Detect plugin. For use on Front End only.
    							 */
    							include_once( ABSPATH . 'wp-admin/includes/plugin.php' );
    
    							// check for plugin using plugin name
    							if ( is_plugin_active( "nextend-twitter-connect/nextend-twitter-connect.php" ) ) {
    							  //plugin is activated
    
    							?>
    
    									<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;"><?php _e( 'Login via Twitter', 'agrg' ); ?></a>
    
    							<?php } ?>
    
    							<?php
    							/**
    							 * Detect plugin. For use on Front End only.
    							 */
    							include_once( ABSPATH . 'wp-admin/includes/plugin.php' );
    
    							// check for plugin using plugin name
    							if ( is_plugin_active( "nextend-google-connect/nextend-google-connect.php" ) ) {
    							  //plugin is activated
    
    							?>
    
    									<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;"><?php _e( 'Login via Google', 'agrg' ); ?></a>
    
    							<?php } ?>
    
    						</div>
    
    					</div>
    
    	    		<?php }
    
    					else echo "<span class='registration-closed'>"._e('Registration is currently disabled. Please try again later.','agrg')."</span>";
    
    				?>
    
    					<div class="span4 log-forms">
    						<h3><?php _e( 'FORGOT PASSWORD', 'agrg' ); ?></h3>
    								<form class="form-item login-form" action="" id="primaryPostForm" method="POST" enctype="multipart/form-data">
    
    									<?php if($_POST) {
    
    										echo "<div id='result' style='margin-bottom: 30px;'><div class='message'><span>".$message."</span></div></div>";
    
    									} ?>
    
    										<?php if($resetSuccess == 1) {
    
    									} else { ?>
    
    											<input id="email" placeholder="<?php _e('Email Address','agrg'); ?>" type="text" name="email" class="text input-textarea half" value="" maxlength="30" />
    
    											<span class="help-text"><?php _e( 'Put your email address for reset password.', 'agrg' ); ?></span>
    
    											<input type="hidden" name="submit" value="Reset" id="submit" />
    											<div class="clearfix"></div>
    
    												<button class="btn form-submit" id="edit-submit" name="op" value="Publish Ad" type="submit"><?php _e('SUBMIT NOW', 'agrg') ?></button>
    
    									<?php } ?>
    
    								</form>
    
    								<div class="clearfix"></div>
    
    						<div class="register-page-title">
    
    							<h5><?php _e( 'Login via Social Media', 'agrg' ); ?></h5>
    
    						</div>
    					<div class="social-btn clearfix">
    							<?php
    							/**
    							 * Detect plugin. For use on Front End only.
    							 */
    							include_once( ABSPATH . 'wp-admin/includes/plugin.php' );
    
    							// check for plugin using plugin name
    							if ( is_plugin_active( "nextend-facebook-connect/nextend-facebook-connect.php" ) ) {
    							  //plugin is activated
    
    							?>
    
    									<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;"><?php _e( 'Login via Facebook', 'agrg' ); ?></a>
    
    							<?php } ?>
    
    							<?php
    							/**
    							 * Detect plugin. For use on Front End only.
    							 */
    							include_once( ABSPATH . 'wp-admin/includes/plugin.php' );
    
    							// check for plugin using plugin name
    							if ( is_plugin_active( "nextend-twitter-connect/nextend-twitter-connect.php" ) ) {
    							  //plugin is activated
    
    							?>
    
    									<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;"><?php _e( 'Login via Twitter', 'agrg' ); ?></a>
    
    							<?php } ?>
    
    							<?php
    							/**
    							 * Detect plugin. For use on Front End only.
    							 */
    							include_once( ABSPATH . 'wp-admin/includes/plugin.php' );
    
    							// check for plugin using plugin name
    							if ( is_plugin_active( "nextend-google-connect/nextend-google-connect.php" ) ) {
    							  //plugin is activated
    
    							?>
    
    									<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;"><?php _e( 'Login via Google', 'agrg' ); ?></a>
    
    							<?php } ?>
    
    						</div>
    
    					</div>
    
    	    	</div>
    
    	    </div>
    
        </section>
    
    <?php get_footer(); ?>
    
Viewing 1 replies (of 1 total)
  • M

    (@zmohammad272)

    To redirect you could add the following code into the functions.php / or a registration plugin. You can put your url on the place of the ‘/pageurl’

    function wpse_19692_registration_redirect() {
        return home_url( '/pageurl' );
    }
    
    add_filter( 'registration_redirect', 'wpse_19692_registration_redirect' );
Viewing 1 replies (of 1 total)
  • The topic ‘Redirect after registration’ is closed to new replies.