Esempio n. 1
0
function cyc_show_registerform()
{
    global $cyc_pluginpath, $cyc_options;
    if (!get_option('users_can_register')) {
        wp_redirect(get_bloginfo('wpurl') . '/wp-login.php?registration=disabled');
        exit;
    }
    $user_login = '';
    $user_email = '';
    if (isset($_POST['user_login'])) {
        if (!$cyc_options['captcha'] || $cyc_options['captcha'] && $_SESSION['security_code'] == $_POST['security_code'] && !empty($_SESSION['security_code'])) {
            unset($_SESSION['security_code']);
            require_once ABSPATH . WPINC . '/registration.php';
            $user_login = $_POST['user_login'];
            $user_email = $_POST['user_email'];
            $errors = custom_register_new_user($user_login, $user_email, @$_POST['password']);
            if (!is_wp_error($errors)) {
                wp_redirect('wp-login.php?checkemail=registered');
                exit;
            }
        } else {
            $user_login = $_POST['user_login'];
            $user_email = $_POST['user_email'];
            $errors = new WP_error();
            $errors->add('captcha', __("<strong>ERROR</strong>: You didn't correctly enter the captcha, please try again."));
        }
    }
    cyc_head("Register");
    cyc_show_errors($errors);
    get_template_part('_user', 'register');
    cyc_footer();
}
Esempio n. 2
0
function cyc_show_loginform()
{
    if (isset($_REQUEST['redirect_to'])) {
        $redirect_to = $_REQUEST['redirect_to'];
    } else {
        $redirect_to = admin_url();
    }
    if (is_ssl() && force_ssl_login() && !force_ssl_admin() && 0 !== strpos($redirect_to, 'https') && 0 === strpos($redirect_to, 'http')) {
        $secure_cookie = false;
    } else {
        $secure_cookie = '';
    }
    $user = wp_signon('', $secure_cookie);
    $redirect_to = apply_filters('login_redirect', $redirect_to, isset($_REQUEST['redirect_to']) ? $_REQUEST['redirect_to'] : '', $user);
    if (!is_wp_error($user)) {
        // If the user can't edit posts, send them to their profile.
        if (!$user->has_cap('edit_posts') && (empty($redirect_to) || $redirect_to == 'wp-admin/')) {
            $redirect_to = admin_url('profile.php');
        }
        wp_safe_redirect($redirect_to);
        exit;
    }
    $errors = $user;
    // Clear errors if loggedout is set.
    if (!empty($_GET['loggedout'])) {
        $errors = new WP_Error();
    }
    cyc_head("Login");
    // If cookies are disabled we can't log in even with a valid user+pass
    if (isset($_POST['testcookie']) && empty($_COOKIE[TEST_COOKIE])) {
        $errors->add('test_cookie', __("<strong>ERROR</strong>: Cookies are blocked or not supported by your browser. You must <a href='http://www.google.com/cookies.html'>enable cookies</a> to login to our site."));
    }
    if (isset($_GET['loggedout']) && TRUE == $_GET['loggedout']) {
        $errors->add('loggedout', __('You are now logged out.'), 'message');
    } elseif (isset($_GET['registration']) && 'disabled' == $_GET['registration']) {
        $errors->add('registerdisabled', __('User registration is currently not allowed.'));
    } elseif (isset($_GET['checkemail']) && 'confirm' == $_GET['checkemail']) {
        $errors->add('confirm', __('Check your e-mail for the confirmation link.'), 'message');
    } elseif (isset($_GET['checkemail']) && 'newpass' == $_GET['checkemail']) {
        $errors->add('newpass', __('Check your e-mail for your new password.'), 'message');
    } elseif (isset($_GET['checkemail']) && 'registered' == $_GET['checkemail']) {
        $errors->add('registered', __('Registration complete. Please check your e-mail.'), 'message');
    }
    cyc_show_errors($errors);
    // login form
    ?>
	<form class="loginform" action="<?php 
    bloginfo('wpurl');
    ?>
/wp-login.php" method="post" >
		<p>
			<label for="user_login"><?php 
    _e('Username:'******'log']));
    ?>
" class="mid" id="user_login" type="text" />
			<br/>
			<label for="user_pass"><?php 
    _e('Password:'******'Remember me');
    ?>
</label>
		</p>
		<p class="submit">
			<input type="submit" name="wp-submit" id="wp-submit" value="<?php 
    _e('Login');
    ?>
 &raquo;" />
			<input type="hidden" name="testcookie" value="1" />
		</p>
	</form>
	<?php 
    cyc_footer();
}