예제 #1
0
function ae_social_login_settings($pages)
{
    $options = AE_Options::get_instance();
    $sections = array();
    /**
     * social settings section
     */
    $user_roles = ae_social_auth_support_role();
    $authentication_page = ae_get_social_connect_page_link();
    $default_role = ae_get_social_login_user_roles_default();
    $sections[] = array('args' => array('title' => __("Social API", ET_DOMAIN), 'id' => 'social-settings', 'icon' => 'B', 'class' => ''), 'groups' => array(array('args' => array('title' => __("Twitter API", ET_DOMAIN), 'id' => 'twitter-api', 'class' => '', 'desc' => __("Enabling this will allow users to login via Twitter.", ET_DOMAIN)), 'fields' => array(array('id' => 'twitter_login', 'type' => 'switch', 'title' => __("Twitter API ", ET_DOMAIN), 'name' => 'twitter_login', 'class' => ''), array('id' => 'et_twitter_key', 'type' => 'text', 'title' => __("Twitter key ", ET_DOMAIN), 'name' => 'et_twitter_key', 'placeholder' => __("Twitter Consumer Key", ET_DOMAIN), 'class' => ''), array('id' => 'et_twitter_secret', 'type' => 'text', 'title' => __("Twitter secret ", ET_DOMAIN), 'name' => 'et_twitter_secret', 'placeholder' => __("Twitter Consumer Secret", ET_DOMAIN), 'class' => ''))), array('args' => array('title' => __("Facebook API", ET_DOMAIN), 'id' => 'facebook-api', 'class' => '', 'desc' => __("Enabling this will allow users to login via Facebook.", ET_DOMAIN)), 'fields' => array(array('id' => 'facebook_login', 'type' => 'switch', 'title' => __("Facebook API ", ET_DOMAIN), 'name' => 'facebook_login', 'class' => ''), array('id' => 'et_facebook_key', 'type' => 'text', 'title' => __("Facebook key ", ET_DOMAIN), 'name' => 'et_facebook_key', 'placeholder' => __("Facebook Application ID", ET_DOMAIN), 'class' => ''), array('id' => 'et_facebook_secret_key', 'type' => 'text', 'title' => __("Facebook secret key ", ET_DOMAIN), 'name' => 'et_facebook_secret_key', 'placeholder' => __("Facebook Secret Key", ET_DOMAIN), 'class' => ''))), array('args' => array('title' => __("Google API", ET_DOMAIN), 'id' => 'google-api', 'class' => '', 'desc' => __("Enabling this will allow users to login via Google.", ET_DOMAIN)), 'fields' => array(array('id' => 'gplus_login', 'type' => 'switch', 'title' => __("Google API ", ET_DOMAIN), 'name' => 'gplus_login', 'class' => ''), array('id' => 'gplus_client_id', 'type' => 'text', 'title' => __("Google key ", ET_DOMAIN), 'name' => 'gplus_client_id', 'placeholder' => __("Client ID", ET_DOMAIN), 'class' => ''), array('id' => 'gplus_secret_id', 'type' => 'text', 'title' => __("Google Secret key ", ET_DOMAIN), 'name' => 'gplus_secret_id', 'placeholder' => __("Google secret key", ET_DOMAIN), 'class' => ''))), array('args' => array('title' => __("LinkedIn API", ET_DOMAIN), 'id' => 'linkedin-api', 'class' => '', 'desc' => __("Enabling this will allow users to login via LinkedIn.", ET_DOMAIN)), 'fields' => array(array('id' => 'linkedin_login', 'type' => 'switch', 'title' => __("LinkedIn API ", ET_DOMAIN), 'name' => 'linkedin_login', 'class' => ''), array('id' => 'linkedin_api_key', 'type' => 'text', 'title' => __("Consumer Key / API Key ", ET_DOMAIN), 'name' => 'linkedin_api_key', 'placeholder' => __("LinkedIn API Key", ET_DOMAIN), 'class' => ''), array('id' => 'linkedin_secret_key', 'type' => 'text', 'title' => __("Consumer Secret / Secret Key ", ET_DOMAIN), 'name' => 'linkedin_secret_key', 'placeholder' => __("LinkedIn secret key", ET_DOMAIN), 'class' => '')))));
    /**
     * social settings section
     */
    $sections[] = array('args' => array('title' => __("General setting", ET_DOMAIN), 'id' => 'social-page-settings', 'icon' => 'y', 'class' => ''), 'groups' => array(array('args' => array('title' => __("Social connect page", ET_DOMAIN), 'id' => 'social-connect', 'class' => '', 'desc' => __("You can create a new page and paste shortcode [social_connect_page] here", ET_DOMAIN)), 'fields' => array(array('id' => 'social_connect', 'type' => 'text', 'title' => __("Social connect page url ", ET_DOMAIN), 'name' => 'social_connect', 'placeholder' => __("eg:http://enginethemes.com/directoryengine/social-connect", ET_DOMAIN), 'class' => '', 'default' => $authentication_page))), array('args' => array('title' => __("Select User roles", ET_DOMAIN), 'id' => 'user_roles', 'class' => '', 'desc' => __("Select the user roles.", ET_DOMAIN)), 'fields' => array(array('id' => 'user-roles', 'type' => 'multi_select', 'data' => $user_roles, 'title' => __("Select user roles", ET_DOMAIN), 'name' => 'social_user_role', 'class' => 'option-item bg-grey-input ', 'placeholder' => __("Select user roles", ET_DOMAIN), 'label' => __("Select user roles", ET_DOMAIN), 'default' => $default_role)))));
    $temp = array();
    foreach ($sections as $key => $section) {
        $temp[] = new AE_section($section['args'], $section['groups'], $options);
    }
    $orderlist = new AE_container(array('class' => 'social-login-settings', 'id' => 'settings'), $temp, $options);
    $pages[] = array('args' => array('parent_slug' => 'et-overview', 'page_title' => __('Social login', ET_DOMAIN), 'menu_title' => __('SOCIAL LOGIN', ET_DOMAIN), 'cap' => 'administrator', 'slug' => 'ae-social-login', 'icon' => 'B', 'desc' => __("setup a way for users to login via their socile network accounts", ET_DOMAIN)), 'container' => $orderlist);
    return $pages;
}
예제 #2
0
 public function confirm_username()
 {
     try {
         if (!isset($_SESSION)) {
             ob_start();
             @session_start();
         }
         // get data
         $data = $_POST['content'];
         $auth_info = unserialize($_SESSION['et_auth']);
         $username = $data['user_login'];
         if (isset($data['user_role']) && $data['user_role'] != '') {
             $user_roles = ae_get_option('social_user_role', false);
             if (!$user_roles) {
                 $user_roles = ae_get_social_login_user_roles_default();
             }
             if ($user_roles && in_array($data['user_role'], $user_roles) && $data['user_role'] != 'Administrator') {
                 $auth_info['role'] = $data['user_role'];
             }
         }
         $et_session = et_read_session();
         if ($et_session['et_social_id']) {
             $social_id = $et_session['et_social_id'];
         } else {
             $social_id = $_SESSION['et_social_id'];
         }
         // verify username
         $ae_user = get_user_by('login', $username);
         $return = array();
         if ($ae_user != false) {
             throw new Exception(__('Username is existed, please choose another one', ET_DOMAIN));
         } else {
             $auth_info['user_login'] = $username;
             // create user
             $ae_user = AE_Users::get_instance();
             $result = $ae_user->insert($auth_info);
             if (is_wp_error($result)) {
                 throw new Exception($result->get_error_message());
             } else {
                 if (empty($social_id)) {
                     throw new Exception(__("Can't find Social ID", ET_DOMAIN));
                 } else {
                     // creating user successfully
                     update_user_meta((int) $result->ID, $this->social_option, $social_id);
                     do_action('et_after_register', $result);
                     wp_set_auth_cookie((int) $result->ID, 1);
                     unset($_SESSION['et_auth']);
                     $return = array('user_id' => $result, 'redirect_url' => home_url());
                 }
             }
         }
         $resp = array('success' => true, 'msg' => '', 'data' => $return);
     } catch (Exception $e) {
         $resp = array('success' => false, 'msg' => $e->getMessage());
     }
     wp_send_json($resp);
 }
예제 #3
0
/**
 * Generate social connect page template;
 */
function ae_page_social_connect()
{
    global $wp_query, $wp_rewrite, $post, $et_data;
    if (!isset($_SESSION)) {
        ob_start();
        @session_start();
    }
    $labels = $et_data['auth_labels'];
    if (isset($_SESSION['et_auth']) && $_SESSION['et_auth'] != '') {
        $auth = unserialize($_SESSION['et_auth']);
    } else {
        wp_redirect(home_url());
    }
    $type = isset($_GET['type']) ? $_GET['type'] : '';
    ?>
	<div class="twitter-auth social-auth social-auth-step1">
	<?php 
    if ($type == 'facebook') {
        ?>
	    <p class="text-page-not social-big"><?php 
        _e('SIGN IN WITH FACEBOOK', ET_DOMAIN);
        ?>
</p>
	    <p class="social-small">
	    <?php 
        printf(__("This seems to be your first time signing in using your Facebook account. <br />If you already have an account with %s, please log in using the form below to link it to your Facebook account. Otherwise, please enter an email address and a password on the form, and a username on the next page to create an account.<br />You will only do this step ONCE. Next time, you'll get logged in right away.", ET_DOMAIN), get_bloginfo('name'));
        ?>
	    </p>
	    <?php 
    } else {
        if ($type == 'twitter') {
            ?>
	    <p class="text-page-not social-big"><?php 
            _e('SIGN IN WITH TWITTER', ET_DOMAIN);
            ?>
</p>
	    <p class="social-small">
	        <?php 
            printf(__("This seems to be your first time signing in using your Twitter account.<br />If you already have an account with %s, please log in using the form below to link it to your Twitter account. Otherwise, please enter an email address and a password on the form, and a username on the next page to create an account.<br > You will only do this step ONCE. Next time, you'll get logged in right away.</p>", ET_DOMAIN), get_bloginfo('name'));
            ?>
	    </p>

	<?php 
        } else {
            if ($type == 'google') {
                ?>
		<p class="text-page-not social-big"><?php 
                _e('SIGN IN WITH GOOGLE+', ET_DOMAIN);
                ?>
</p>
	    <p class="social-small">
	        <?php 
                printf(__("This seems to be your first time signing in using your Google+ account.If you already have an account, please log in using the form below to link it to your Google+  account. Otherwise, please enter an email address and a password on the form, and a username on the next page to create an account.You will only do this step ONCE. Next time, you'll get logged in right away.</p>", ET_DOMAIN), get_bloginfo('name'));
                ?>
		</p>
	<?php 
            } else {
                if ($type == 'linkedin') {
                    ?>
		<p class="text-page-not social-big"><?php 
                    _e('SIGN IN WITH LINKEDIN', ET_DOMAIN);
                    ?>
</p>
	    <p class="social-small">
	        <?php 
                    printf(__("This seems to be your first time signing in using your Linkedin account.If you already have an account, please log in using the form below to link it to your Linkedin  account. Otherwise, please enter an email address and a password on the form, and a username on the next page to create an account.You will only do this step ONCE. Next time, you'll get logged in right away.</p>", ET_DOMAIN), get_bloginfo('name'));
                    ?>
		</p>
	<?php 
                }
            }
        }
    }
    ?>
	    <form id="form_auth" method="post" action="">
	        <div class="social-form">
	            <input type="hidden" name="et_nonce" value="<?php 
    echo wp_create_nonce('authentication');
    ?>
">
	            <input type="text" name="user_email" value="<?php 
    if (isset($_SESSION['user_email'])) {
        echo $_SESSION['user_email'];
    }
    ?>
"  placeholder="<?php 
    _e('Email', ET_DOMAIN);
    ?>
">
	            <input type="password" name="user_pass"  placeholder="<?php 
    _e('Password', ET_DOMAIN);
    ?>
">
	            <input type="submit" value="Submit">
	        </div>
	    </form>
	</div>
	<div class="social-auth social-auth-step2">
	    <p class="text-page-not social-big"><?php 
    echo $labels['title'];
    ?>
</p>
	    <p class="social-small"><?php 
    _e('Please provide a username to continue', ET_DOMAIN);
    ?>
</p>
	    <form id="form_username" method="post" action="">
	        <div class="social-form">
	            <input type="hidden" name="et_nonce" value="<?php 
    echo wp_create_nonce('authentication');
    ?>
">
	            <input type="text" name="user_login" value="<?php 
    echo isset($auth['user_login']) ? $auth['user_login'] : "";
    ?>
" placeholder="<?php 
    _e('Username', ET_DOMAIN);
    ?>
">
	            <?php 
    $social_user_roles = ae_get_option('social_user_role', false);
    if (!$social_user_roles) {
        $social_user_roles = ae_get_social_login_user_roles_default();
    }
    if ($social_user_roles && count($social_user_roles) >= 1) {
        ?>
	            	  <select name="user_role" class="sc_user_role">
	            	  	<?php 
        foreach ($social_user_roles as $key => $value) {
            ?>
		            	<option value="<?php 
            echo $value;
            ?>
"><?php 
            echo $value;
            ?>
</option>
		           		<?php 
        }
        ?>
	            	  </select>
	            <?php 
    }
    ?>
	            <input type="submit" value="Submit">
	        </div>
	    </form>
	</div>
<?php 
}