コード例 #1
0
function mgm_generate_facebook_registration()
{
    // fb registration form
    $fb_registration_form = '';
    $url = get_permalink();
    $callback_url = strpos($url, '?') !== false ? $url : $url . '?';
    $callback_url .= 'connect=facebook_registration';
    // check auto login
    if ($html = mgm_try_auto_login()) {
        return $html;
    }
    $fb_registration_form = mgm_registration_form_facebook_form($fb_registration_form, $callback_url);
    mgm_pre_process_facebook_registration();
    // set error !
    if (isset($errors) && is_object($errors)) {
        // get error
        if ($error_html = mgm_set_errors($errors, true)) {
            $fb_registration_form .= $error_html;
        }
    }
    return $fb_registration_form;
}
コード例 #2
0
/**
 * custom user login form, output by [user_register] shortcode
 *
 * @param bool $use_default_links
 * @param string $html
 */
function mgm_user_login_form($use_default_links = true)
{
    //fb logins i.e. facebook connect errors
    global $fb_errors;
    // hide from logged in user
    if (is_user_logged_in()) {
        // not logout call to self
        if (mgm_get_var('action', '', true) != 'logout') {
            return __('You are already logged in!', 'mgm');
        }
    }
    // check auto login
    if ($html = mgm_try_auto_login()) {
        return $html;
    }
    // init errors
    $fb_errors = $errors = null;
    // system
    $system_obj = mgm_get_class('system');
    // process hooked logins i.e. facebook connect
    do_action('mgm_user_login_pre_process');
    // check security before processing form
    if (isset($_POST['log'])) {
        if (!wp_verify_nonce(mgm_post_var('_mgmnonce_user_login'), 'user_login')) {
            mgm_security_error('user_login');
        }
    }
    // issue #1203
    if (empty($fb_errors)) {
        $errors = mgm_process_user_login();
    } else {
        $errors = $fb_errors;
    }
    // action
    $form_action = mgm_get_custom_url('login');
    // init
    $user_login = $user_pwd = $html = '';
    //check logged in cookie:
    $rememberme = !empty($_POST['rememberme']);
    $interim_login = isset($_REQUEST['interim-login']);
    // login
    if (isset($_POST['log'])) {
        $user_login = esc_attr(stripslashes($_POST['log']));
        // issue# 525
    } elseif ($cookie_userid = wp_validate_auth_cookie('', 'logged_in')) {
        //check a valid logged cookie exists
        // cookie
        $arr_loggedin_cookie = wp_parse_auth_cookie('', 'logged_in');
        // get mgm_member
        $member = mgm_get_member($cookie_userid);
        // mark checked
        $rememberme = true;
        // get login from cookie
        $user_login = esc_attr(stripslashes($arr_loggedin_cookie['username']));
        // password from member object
        // issue#: 672
        $user_pwd = mgm_decrypt_password($member->user_password, $cookie_userid);
    }
    // redirect
    $redirect_to = isset($_REQUEST['redirect_to']) ? $_REQUEST['redirect_to'] : '';
    // start html
    $html = '';
    // set error !
    if (isset($errors) && is_object($errors)) {
        // get error
        if ($error_html = mgm_set_errors($errors, true)) {
            $html .= $error_html;
        }
    }
    // check
    if (bool_from_yn($system_obj->get_setting('enable_email_as_username'))) {
        $email_username_label = __('Email', 'mgm');
    } else {
        $email_username_label = __('Username', 'mgm');
    }
    // start form
    $html .= '<form class="mgm_form" name="loginform" id="loginform" action="' . $form_action . '" method="post">
				<div>
					<label>' . $email_username_label . '<br />
					<input type="text" name="log" id="user_login" class="input" value="' . esc_attr($user_login) . '" size="40" tabindex="10" /></label>
				</div>
				<div>
					<label>' . __('Password', 'mgm') . '<br />
					<input type="password" name="pwd" id="user_pass" class="input" value="' . esc_attr($user_pwd) . '" size="40" tabindex="20" /></label>
				</div>';
    //Issue #782
    $html .= mgm_get_captcha_field('mgm_login_field');
    // login form, fetch as return
    // do_action('login_form');
    // custom
    $html .= apply_filters('mgm_login_form', $html);
    // forget
    $html .= '<div class="forgetmenot">
				 <label>
					<input name="rememberme" type="checkbox" id="rememberme" value="forever" tabindex="90" ' . checked($rememberme, true, false) . '  /> ' . __('Remember Me', 'mgm') . '
				 </label>
			  </div>';
    // buttons
    $buttons = array(sprintf('<input class="button mgm-login-button" type="submit" name="wp-submit" id="wp-submit" value="%s" tabindex="100" />', __('Log In', 'mgm')));
    // apply filters
    $buttons_s = implode(apply_filters('mgm_login_form_buttons_sep', ' &nbsp; '), apply_filters('mgm_login_form_buttons', $buttons));
    // append
    $html .= sprintf('<div class="login-page-buttons">%s</div>', $buttons_s);
    if ($system_obj->get_setting('disable_testcookie') == 'N') {
        // hiddens
        $html .= '<input type="hidden" name="testcookie" value="1" /> ';
    }
    // intrim
    if ($interim_login) {
        $html .= '<input type="hidden" name="interim-login" value="1" />';
    } else {
        $html .= '<input type="hidden" name="redirect_to" value="' . esc_attr($redirect_to) . '" />';
    }
    // nonce
    $html .= wp_nonce_field('user_login', '_mgmnonce_user_login', true, false);
    // end form
    $html .= '</form>';
    // after links
    $links = array();
    // interim_login
    if (!$interim_login) {
        // check mail will not have any
        if (!isset($_GET['checkemail']) || isset($_GET['checkemail']) && !in_array($_GET['checkemail'], array('confirm', 'newpass'))) {
            // register
            if (get_option('users_can_register')) {
                $links[] = sprintf('<a class="mgm-register-link" href="%s">%s</a>', mgm_get_custom_url('register'), __('Register', 'mgm'));
            }
            // lostpassword
            $links[] = sprintf('<a class="mgm-lostpassword-link" href="%s" title="%s">%s</a>', mgm_get_custom_url('lostpassword'), __('Password Lost and Found', 'mgm'), __('Lost your password?', 'mgm'));
        }
    }
    // apply filters
    $links_s = implode(apply_filters('mgm_login_form_after_links_sep', ' | '), apply_filters('mgm_login_form_after_links', $links));
    // appaend
    $html .= sprintf('<div class="login-page-links">%s</div>', $links_s);
    // scripts & styles --------------------
    // focus
    $focus = $user_login || $interim_login ? 'user_pass' : 'user_login';
    // script
    $script = 'function wp_attempt_focus(){setTimeout( function(){ try{ d = document.getElementById("' . $focus . '"); d.focus();} catch(e){}}, 200);}';
    // focus
    if (@(!$error)) {
        $script .= 'wp_attempt_focus();';
    }
    // script
    $script = sprintf('<script type="text/javascript">%s</script>', apply_filters('mgm_login_form_inline_script', $script));
    // scripts
    $html .= apply_filters('mgm_login_form_scripts', $script);
    // style
    $style = '.login-page-links, .login-page-buttons{margin-top:10px; clear:both}';
    // style
    $style = sprintf('<style type="text/css">%s</style>', apply_filters('mgm_login_form_inline_style', $style));
    // style
    $html .= apply_filters('mgm_login_form_styles', $style);
    // apply filters and return
    return apply_filters('mgm_login_form_html', $html);
}