File: /mnt/data/ifa-wp/wp-content/themes/dreamsrent/templates/register-form.php
<?php
/**
* Template Name: Register Template
*
* This is the template that displays the registration page.
*
* @package Dreamsrent
*/
get_header();
if (is_user_logged_in()) {
$dashboard_page = dreamsrent_fl_framework_getoptions('dashboard_page');
if ((isset($dashboard_page) && $dashboard_page != '')) {
wp_redirect(get_permalink($dashboard_page));
exit();
}
}
if ($_POST) {
$username = sanitize_user($_POST['username']);
$email = sanitize_email($_POST['email']);
$password = $_POST['password'];
$confirm_password = $_POST['confirm_password'];
if ($password !== $confirm_password) {
$error_message = 'Passwords do not match.';
} else {
$user_id = wp_create_user($username, $password, $email);
if (is_wp_error($user_id)) {
$error_message = $user_id->get_error_message();
} else {
// Get Redux options
$from_name = dreamsrent_fl_framework_getoptions('emails_name') ?: get_bloginfo('name');
$from_email = dreamsrent_fl_framework_getoptions('emails_from_email') ?: get_bloginfo('admin_email');
$disable_welcome_email = dreamsrent_fl_framework_getoptions('welcome_email_enabled');
$login_link_get = dreamsrent_fl_framework_getoptions('header_login_link');
$login_link = esc_url(get_permalink($login_link_get));
$email_logo = dreamsrent_fl_framework_getoptions('email_logo');
// $email_logo_url = $email_logo['url'];
if (is_array($email_logo) && isset($email_logo['url'])) {
$email_logo_url = $email_logo['url'];
} else {
$email_logo_url = ''; // or some default value
}
$email_subject_get = dreamsrent_fl_framework_getoptions('listing_welcome_email_subject');
$email_subject = isset($email_subject_get) ? $email_subject_get : __('Welcome to {site_name}', 'dreamsrent');
$email_content_raw = dreamsrent_fl_framework_getoptions('listing_welcome_email_content') ?: 'Hi {user_name}, Welcome to our website.';
// Only send the welcome email if itβs not disabled
if ($disable_welcome_email) {
// Replace placeholders in the email content
$email_subject = str_replace('{site_name}', get_bloginfo('name'), $email_subject);
$email_content = str_replace(
['{user_mail}', '{user_name}', '{site_name}','{login}'],
[$email, $username, get_bloginfo('name'), $login_link],
$email_content_raw
);
$message = '<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<style>
body { font-family: Arial, sans-serif; color: #333; line-height: 1.6; }
.container { max-width: 600px; margin: 0 auto; padding: 20px; background-color: #f9f9f9; border: 1px solid #ddd; }
.header { text-align: center; margin-bottom: 30px; }
.header img { max-width: 150px; }
.content { background: #fff; padding: 20px; border-radius: 5px; }
.content h2 { color: #333; }
.content p { margin-bottom: 20px; }
.content ul { padding-left:0px; }
.button { text-align: center; margin-top: 20px; }
.button a { background-color: #0073e6; color: #fff; padding: 12px 20px; border-radius: 5px; text-decoration: none; font-weight: bold; }
.footer { margin-top: 30px; text-align: center; color: #999; font-size: 12px; }
</style>
</head>
<body>
<div class="container">
<div class="header">';
if (!empty($email_logo_url)) {
$message .= '<img src="' . esc_url($email_logo_url) . '" alt="Logo">';
}
$message .= '</div>
<div class="content">' . $email_content . '</div>
<div class="footer">
© ' . date("Y") . ' ' . get_bloginfo('name') . '. All rights reserved.
</div>
</div>
</body>
</html>';
// Prepare email headers
$headers = [
'Content-Type: text/html; charset=UTF-8',
'From: ' . $from_name . ' <' . $from_email . '>',
];
dreamsrent_send_email($email, $email_subject, $message, $headers);
}
// π Auto login the user
wp_clear_auth_cookie();
wp_set_current_user($user_id);
wp_set_auth_cookie($user_id);
do_action('wp_login', $username, get_user_by('id', $user_id));
// Redirect to login page after registration
// π Redirect after login
$redirect_page = dreamsrent_fl_framework_getoptions('after_register_redirect'); // Redux option
if (!empty($redirect_page)) {
wp_redirect(get_permalink($redirect_page));
} else {
wp_redirect(home_url()); // fallback
}
exit;
}
}
}
?>
<?php //et_template_part('templates/header/header', 'centerlogo'); ?>
<div class="login-wrapper">
<div class="loginbox">
<div class="login-auth">
<div class="login-auth-wrap">
<h1><?php echo get_the_title(); ?></h1>
<form method="post" action="">
<div class="input-block">
<label for="username" class="form-label"><?php echo esc_html__('Username ', 'dreamsrent'); ?><span class="text-danger"><?php echo esc_html__('*', 'dreamsrent'); ?></span></label>
<input type="text" name="username" class="form-control" required>
</div>
<!-- <div class="input-block">
<label for="email" class="form-label"><?php echo esc_html__('Email ', 'dreamsrent'); ?><span class="text-danger"><?php echo esc_html__('*', 'dreamsrent'); ?></span></label>
<input type="email" name="email" class="form-control">
</div> -->
<div class="input-block">
<label for="email" class="form-label"><?php echo esc_html__('Email ', 'dreamsrent'); ?><span class="text-danger"><?php echo esc_html__('*', 'dreamsrent'); ?></span></label>
<div class="input-group">
<input type="hidden" name="email_hidden" id="email_hidden" value="">
<input type="email" name="email" class="form-control" id="email" required>
<?php
$otp_switch = dreamsrent_fl_framework_getoptions('otp_switch');
if($otp_switch == '1')
{ ?>
<button type="button" id="send_otp" class="btn btn-secondary"><?php echo esc_html_e('Send OTP', 'dreamsrent'); ?></button>
<?php } ?>
</div>
</div>
<div class="input-block" id="otp_block" style="display: none;">
<label for="otp" class="form-label"><?php echo esc_html__('Enter OTP', 'dreamsrent'); ?><span class="text-danger"><?php echo esc_html__('*', 'dreamsrent'); ?></span></label>
<div class="input-group">
<input type="text" name="otp" class="form-control" id="otp" maxlength="6">
<button type="button" id="verify_otp" class="btn btn-secondary"><?php echo esc_html__('Verify ', 'dreamsrent'); ?></button>
</div>
</div>
<div class="input-block">
<label for="password" class="form-label"><?php echo esc_html__('Password ', 'dreamsrent'); ?><span class="text-danger"><?php echo esc_html__('*', 'dreamsrent'); ?></span></label>
<div class="pass-group">
<input type="password" name="password" id="password" class="form-control pass-input" required>
<span class="fas fa-eye-slash toggle-password"></span>
</div>
</div>
<div class="input-block">
<label for="confirm_password" class="form-label"><?php echo esc_html__('Confirm Password ', 'dreamsrent'); ?><span class="text-danger"><?php echo esc_html__('*', 'dreamsrent'); ?></span></label>
<div class="pass-group">
<input type="password" name="confirm_password" id="confirm_password" class="form-control pass-input" required>
<span class="fas fa-eye-slash toggle-password"></span>
</div>
<span id="password_match_error" style="color: red;"></span>
</div>
<?php wp_nonce_field('custom-registration', 'registration_nonce'); ?>
<input type="submit" id="signup_button" class="btn btn-wid btn-outline-light w-100 btn-size mt-1" value="<?php echo esc_attr__('Sign Up', 'dreamsrent'); ?>" >
<div class="text-center dont-have"><?php echo esc_html__('Already have an Account? ', 'dreamsrent'); ?>
<?php
$login_page = dreamsrent_fl_framework_getoptions('header_login_link');
if ((isset($login_page) && $login_page != '')) {
?>
<a href="<?php echo esc_url(get_permalink($login_page)); ?>"><?php echo get_the_title( $login_page ); ?></a>
<?php } ?>
</div>
</form>
</div>
</div>
</div>
</div>
<?php //get_template_part('templates/footer/footer', 'copyright');
get_footer();?>