<?php
if ( ! defined( 'ABSPATH' ) ) exit; 

function sample_extra() { 
$user = wp_get_current_user();
$allowed_roles = array( 'subscriber' );	
	if( array_intersect($allowed_roles, $user->roles ) ) {
	}
}
//add_action( 'init', 'sample_extra' );

//add_filter( 'login_redirect', 'custom_login_redirect', 10, 3 );
function custom_login_redirect( $redirect_to, $request, $user ) {
	$user = wp_get_current_user();
	$allowed_roles = array( 'subscriber' );	
	if( array_intersect($allowed_roles, $user->roles ) ) {
		return home_url(); 
	}
	
	// Redirects to the site's home URL
}

function reg_log_form_register() { 
global $wpdb, $post, $opt_themes, $wp_query; 
?>  

		<?php 

		$error		= '';
		$success	= ''; 
		global $wpdb, $PasswordHash, $current_user, $user_ID;
		if(isset($_POST['task']) && $_POST['task'] == 'register' ) {	
		$password1	= $wpdb->escape(trim($_POST['password1']));
		$password2	= $wpdb->escape(trim($_POST['password2']));
		$first_name	= $wpdb->escape(trim($_POST['first_name']));
		$last_name	= $wpdb->escape(trim($_POST['last_name']));
		$email		= $wpdb->escape(trim($_POST['email']));
		$username	= $wpdb->escape(trim($_POST['username']));
		if( $email == "" || $password1 == "" || $password2 == "" || $username == "" || $first_name == "" || $last_name == "") {
			$error	= __($opt_themes['o_text_2k'], TEXT_DOMAIN);
		} else if(!filter_var($email, FILTER_VALIDATE_EMAIL)) {
			$error	= __($opt_themes['o_text_2l'], TEXT_DOMAIN);
		} else if(email_exists($email) ) {
			$error	= __($opt_themes['o_text_2m'], TEXT_DOMAIN);
		} else if($password1 <> $password2 ){
			$error	= __($opt_themes['o_text_2n'], TEXT_DOMAIN);
		} else { 
			$user_id	= wp_insert_user( array (
			'first_name'	=> apply_filters('pre_user_first_name', $first_name), 
			'last_name'		=> apply_filters('pre_user_last_name', $last_name), 
			'user_pass'		=> apply_filters('pre_user_user_pass', $password1), 
			'user_login'	=> apply_filters('pre_user_user_login', $username), 
			'user_email'	=> apply_filters('pre_user_user_email', $email), 
			'role'			=> 'subscriber' 
			) );
			if( is_wp_error($user_id) ) {
			$error	= __($opt_themes['o_text_2o'], TEXT_DOMAIN);	
			} else {
			do_action('user_register', $user_id);		
			$success	= __($opt_themes['o_text_2p'], TEXT_DOMAIN);	
			}
		}
		}
		?>
	
		<form method="post" name="registration" id="registration">
		<div class="pform-cont-form form-list">
		<h1 class="title"><?php _e($opt_themes['o_text_2ba'], TEXT_DOMAIN); ?></h1>
	
		<div class="form-group">
		<div class="form-group-label">
		<label for="username"><?php _e($opt_themes['o_text_2b'], TEXT_DOMAIN); ?></label>
		</div>
		<input type="text" class="form-control" type="text" name="username" id="username" required>
		</div>
		
		<div class="form-group">
		<div class="form-group-label">
		<label for="username"><?php _e($opt_themes['o_text_2e'], TEXT_DOMAIN); ?></label>
		</div>
		<input type="text" class="form-control" type="text" name="first_name" id="first_name" required>
		</div>
		
		<div class="form-group">
		<div class="form-group-label">
		<label for="username"><?php _e($opt_themes['o_text_2f'], TEXT_DOMAIN); ?></label>
		</div>
		<input type="text" class="form-control" type="text" name="last_name" id="last_name" required>
		</div>
		
		<div class="form-group">
		<div class="form-group-label">
		<label for="email"><?php _e($opt_themes['o_text_2g'], TEXT_DOMAIN); ?></label>
		</div>
		<input class="form-control" type="email" name="email" id="email" required>
		</div>
		
		<div class="form-group">
		<div class="form-group-label">
		<label for="password1"><?php _e($opt_themes['o_text_2h'], TEXT_DOMAIN); ?></label>
		</div>
		<input class="form-control" type="password" name="password1" id="password1" required>
		</div>
		
		<div class="form-group">
		<div class="form-group-label">
		<label for="password2"><?php _e($opt_themes['o_text_2h2'], TEXT_DOMAIN); ?></label>
		</div>
		<input class="form-control" type="password" name="password2" id="password2" required>
		</div>
	 
		<div class="form-submit btn-group">
		<button class="btn btn-fill btn-block" type="submit" name="submit"><span class="btn-cont"><?php _e($opt_themes['o_text_2i'], TEXT_DOMAIN); ?></span></button>
		<button class="btn btn-line btn-block dialog-btn" type="button"><span class="btn-cont"><?php _e($opt_themes['o_text_2j'], TEXT_DOMAIN); ?></span></button>
		</div>
	 
		</div>
		<input name="submit_reg" type="hidden" id="submit_reg" value="submit_reg">
		<input type="hidden" name="task" value="register" />
		</form>

		<?php if($error!= "") {?>
		<div id="DLEPush" class="DLEPush top-right jGrowl">
		<div class="DLEPush-notification"></div>
		<div class="DLEPush-notification wrapper push-error">
		<button class="DLEPush-close">×</button>
		<div class="DLEPush-icon"><svg width="24" height="28" fill="currentColor" viewBox="0 0 24 28"><path d="M20.5 13.953c0-1.703-0.5-3.281-1.359-4.609l-11.781 11.766c1.344 0.875 2.938 1.391 4.641 1.391 4.688 0 8.5-3.828 8.5-8.547zM4.891 18.625l11.797-11.781c-1.344-0.906-2.953-1.422-4.688-1.422-4.688 0-8.5 3.828-8.5 8.531 0 1.734 0.516 3.328 1.391 4.672zM24 13.953c0 6.656-5.375 12.047-12 12.047s-12-5.391-12-12.047c0-6.641 5.375-12.031 12-12.031s12 5.391 12 12.031z"></path></svg></div>
		<div class="DLEPush-header"></div>
		<div class="DLEPush-message"><?php echo $error; ?></div>
		</div>
		</div>
		<?php } else if($success != "") {?>
		<div id="DLEPush" class="DLEPush top-right jGrowl">
		<div class="DLEPush-notification"></div>
		<div class="DLEPush-notification wrapper push-success">
		<button class="DLEPush-close">×</button>
		<div class="DLEPush-icon"><svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" fill="currentColor" viewBox="0 0 256 256"><path d="M173.66,98.34a8,8,0,0,1,0,11.32l-56,56a8,8,0,0,1-11.32,0l-24-24a8,8,0,0,1,11.32-11.32L112,148.69l50.34-50.35A8,8,0,0,1,173.66,98.34ZM232,128A104,104,0,1,1,128,24,104.11,104.11,0,0,1,232,128Zm-16,0a88,88,0,1,0-88,88A88.1,88.1,0,0,0,216,128Z"></path></svg></div>
		<div class="DLEPush-header"></div><div class="DLEPush-message"><?php echo $success; ?></div>
		</div>
		</div>
		<?php } ?>
	 

<?php
}

function reg_log_cp() { 
global $wpdb, $post, $opt_themes, $wp_query; 
?>  
<div class="pageform-copyright">
	<div class="copyright"><?php echo $opt_themes['ft_cp']; ?></div>
</div>
<?php
}

function reg_log_() { 
global $wpdb, $post, $opt_themes, $wp_query; 
?>  

<?php
}