Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <table class="form-table">
- <tr>
- <th><label for="user_website">User website</label></th>
- <td>
- <!--<select multiple name="user_web[]">-->
- <?php foreach($allsites as $site):
- $bllogdetail = get_blog_details($site['blog_id']);
- $slelected = in_array($site['blog_id'], $usermeta)?"checked='checked'":"";
- $blogname=!empty($bllogdetail->blogname)?$bllogdetail->blogname:"Sub-Site ".$site['blog_id'];
- ?>
- <!--<option <?php //echo $slelected; ?> value="<?php //echo $site['blog_id'] ?>"><?php //echo $bllogdetail->blogname ?></option>-->
- <input type="checkbox" <?php echo $slelected;?> name="user_web[]" value="<?php echo $site['blog_id'] ?>" />
- <label><?php echo $blogname; ?></label><br />
- <?php endforeach; ?>
- <!--</select>-->
- <span class="description">User allowed to visit website.</span>
- </td>
- </tr>
- </table>
- <h3>Visiblity</h3>
- <table class="form-table">
- <tr>
- <th><label for="Visiblity">Base</label></th>
- <td>
- <select name="visiblity">
- <option value="public" <?php if($visiblity=='public') { echo "selected=selected"; } ?>>Public</option>
- <option value="private" <?php if($visiblity=='private') { echo "selected=selected"; } ?>>Private</option>
- </select>
- </td>
- </tr>
- </table>
- <?php
- $blogstxt=implode("",$blogs);
- //send email
- $user_info = get_userdata($userid);
- $name=$user_info->user_firstname."".$user_info->user_lastname;
- $name=trim($name)==""?$user_info->display_name:$name;
- $from=get_option( 'admin_email' );
- $sitename=get_option( 'blogname' );
- $to=$user_info->user_login;
- $sub="Your new user account details for the $sitename site";
- $headers = "MIME-Version: 1.0n" .
- "From: $sitename<$from> n" .
- "Content-Type: text/html; charset="" . get_settings('blog_charset') . ""n";
- $msg="
- <p align="center">
- <img src="http://plpcic.co.uk/wp-content/uploads/2015/03/logo_PLP.png" />
- </p>
- Dear $name,<br /><br />
- function __construct(){
- $params = array(
- 'description' => 'Sidebar Login to Wordpress Account',
- 'name' => 'Ds Sidebar Login Widget'
- );
- //Enque Style sheet
- wp_enqueue_style( 'tp-sidebar-login', plugins_url( 'assets/css/ds-sidebar-login.css', __FILE__ ));
- //Overriding Parent Class's constructor. 3 parameters - id,name,parameters
- parent::__construct('SidebarLogin', '', $params);
- }
- /*This method is responsible for updating the widget option form*/
- public function update( $new_instance, $old_instance ) {
- $instance = array();
- $instance = $old_instance;
- $instance['title'] = strip_tags($new_instance['title']);
- $instance['chk_show_avatar'] = strip_tags($new_instance['chk_show_avatar']);
- $instance['chk_show_user'] = strip_tags($new_instance['chk_show_user']);
- $instance['chk_show_remember'] = strip_tags($new_instance['chk_show_remember']);
- $instance['chk_show_register'] = strip_tags($new_instance['chk_show_register']);
- $instance['chk_show_forgot'] = strip_tags($new_instance['chk_show_forgot']);
- $instance['chk_show_dash'] = strip_tags($new_instance['chk_show_dash']);
- $instance['chk_show_profile'] = strip_tags($new_instance['chk_show_profile']);
- $instance['chk_show_postcount'] = strip_tags($new_instance['chk_show_postcount']);
- return $instance;
- }
- /*
- * This function is responsible for displaying forms
- * This method accepts a parameter which is an array
- */
- public function form($instance){
- /*An array containing default values when the widget will be used first time*/
- $defaults = array(
- 'title' => 'Login',
- 'chk_show_avatar' => 'on',
- 'chk_show_user' => 'on',
- 'chk_show_remember' => 'on',
- 'chk_show_register' => 'on',
- 'chk_show_forgot' => 'on',
- 'chk_show_dash' => 'on',
- 'chk_show_postcount' => 'on',
- 'chk_show_profile' => 'on'
- );
- $instance = wp_parse_args( (array) $instance, $defaults );
- extract($instance, EXTR_SKIP);
- ?>
- <!-- Text field for Title -->
- <p>
- <label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title', 'dsslw_text_domain'); ?></label>
- <input
- class="widefat"
- type="text"
- id="<?php echo $this->get_field_id('title'); ?>"
- name="<?php echo $this->get_field_name('title'); ?>"
- value="<?php if(isset($title)) echo esc_attr($title); ?>"
- />
- </p>
- <!-- Checkbox to turn on/off the option to display avatar -->
- <p>
- <input
- type="checkbox"
- <?php checked("$chk_show_avatar", 'on' );?>
- class="checkbox"
- id="<?php echo $this->get_field_id('chk_show_avatar'); ?>"
- name="<?php echo $this->get_field_name('chk_show_avatar'); ?>"
- />
- <label for="<?php echo $this->get_field_id('chk_show_avatar'); ?>"><?php _e('Show Avatar', 'dsslw_text_domain'); ?></label>
- </p>
- <!-- Checkbox to turn on/off the option to display Logged in user name -->
- <p>
- <input
- type="checkbox"
- <?php checked("$chk_show_user", 'on' );?>
- class="checkbox"
- id="<?php echo $this->get_field_id('chk_show_user'); ?>"
- name="<?php echo $this->get_field_name('chk_show_user'); ?>"
- />
- <label for="<?php echo $this->get_field_id('chk_show_user'); ?>"><?php _e('Show Logged in User name', 'dsslw_text_domain'); ?></label>
- </p>
- <!-- Checkbox to turn on/off the option to display Dashboard link when logged in -->
- <p>
- <input
- type="checkbox"
- <?php checked("$chk_show_dash", 'on' ); ?>
- class="checkbox"
- id="<?php echo $this->get_field_id('chk_show_dash'); ?>"
- name="<?php echo $this->get_field_name('chk_show_dash'); ?>"
- />
- <label for="<?php echo $this->get_field_id('chk_show_dash'); ?>"> <?php _e('Show Dashboard Link', 'dsslw_text_domain'); ?> </label>
- </p>
- <!-- Checkbox to turn on/off the option to display profile link when logged in -->
- <p>
- <input
- type="checkbox"
- <?php checked("$chk_show_profile", 'on' ); ?>
- class="checkbox"
- id="<?php echo $this->get_field_id('chk_show_profile'); ?>"
- name="<?php echo $this->get_field_name('chk_show_profile'); ?>"
- />
- <label for="<?php echo $this->get_field_id('chk_show_profile'); ?>"> <?php _e('Show Profile Link', 'dsslw_text_domain'); ?> </label>
- </p>
- <!-- Checkbox to turn on/off the option to display Remember me option when not logged in -->
- <p>
- <input
- type="checkbox"
- <?php checked("$chk_show_remember", 'on' ); ?>
- class="checkbox"
- id="<?php echo $this->get_field_id('chk_show_remember'); ?>"
- name="<?php echo $this->get_field_name('chk_show_remember'); ?>"
- />
- <label for="<?php echo $this->get_field_id('chk_show_remember'); ?>"> <?php _e('Show Remember me', 'dsslw_text_domain'); ?> </label>
- </p>
- <!-- Checkbox to turn on/off the option to display Register link on login form -->
- <p>
- <input
- type="checkbox"
- <?php checked("$chk_show_register", 'on' ); ?>
- class="checkbox"
- id="<?php echo $this->get_field_id('chk_show_register'); ?>"
- name="<?php echo $this->get_field_name('chk_show_register'); ?>"
- />
- <label for="<?php echo $this->get_field_id('chk_show_register'); ?>"> <?php _e('Show Register Link', 'dsslw_text_domain'); ?> </label>
- </p>
- <!-- Checkbox to turn on/off the option to display Forgot Password link on login form -->
- <p>
- <input
- type="checkbox"
- <?php checked("$chk_show_forgot", 'on' ); ?>
- class="checkbox"
- id="<?php echo $this->get_field_id('chk_show_forgot'); ?>"
- name="<?php echo $this->get_field_name('chk_show_forgot'); ?>"
- />
- <label for="<?php echo $this->get_field_id('chk_show_forgot'); ?>"> <?php _e('Show Forgotten Password Link', 'dsslw_text_domain'); ?> </label>
- </p>
- <!-- Checkbox to turn on/off the option to display Post count -->
- <p>
- <input
- type="checkbox"
- <?php checked("$chk_show_postcount", 'on' ); ?>
- class="checkbox"
- id="<?php echo $this->get_field_id('chk_show_postcount'); ?>"
- name="<?php echo $this->get_field_name('chk_show_postcount'); ?>"
- />
- <label for="<?php echo $this->get_field_id('chk_show_postcount'); ?>"> <?php _e('Show Post Count', 'dsslw_text_domain'); ?> </label>
- </p>
- <?php
- }
- /*
- *This method is responsible for displaying the outputs in the widgetized area
- */
- public function widget($args, $instance){
- extract($args);
- extract($instance);
- global $user_login;
- // Setting default title when nothing is set from widget option
- if(empty($title)){
- $title = __("Member's Login", "dsslw_text_domain");
- }
- else{
- $title = apply_filters('widget_title', $title );
- }
- if(is_user_logged_in()){
- $user_info = get_user_by('login', $user_login);
- $title = (!empty($user_info->first_name) || !empty($user_info->last_name))? __('Welcome','dsslw_text_domain')." ".$user_info->first_name." ".$user_info->last_name : __('Welcome','dsslw_text_domain')." ".$user_login;
- }
- echo $before_widget;
- echo $before_title;
- echo $title;
- echo $after_title;
- $redirect = site_url();
- if (isset($_GET['login'])) {
- $login = $_GET['login']; // This variable is used when login failure occurs
- $current_error = $_GET['errcode']; // This variable is used to display the type of error during login
- if ($login == 'failed'){
- if ($current_error == "empty_username" || $current_error == "empty_password"){
- $error_msg = __('Enter both Username and Password', 'dsslw_text_domain');
- }
- elseif($current_error == 'invalid_username'){
- $error_msg = __('Username is not registered', 'dsslw_text_domain');
- }
- elseif($current_error == 'incorrect_password'){
- $error_msg = __('Incorrect Password', 'dsslw_text_domain');
- }
- echo "<div id='message' class='error fade'><p><strong>".$error_msg."</strong></p></div>";
- }
- }
- /*Check if user is logged in then show user information and logout,dashboardand profile link*/
- if (is_user_logged_in()) {
- ?>
- <div class="sidebar-login-info">
- <?php
- if ($chk_show_avatar == "on"){
- $show_avatar = isset( $show_avatar ) ? $show_avatar : 1;
- if ( $show_avatar == 1 )
- echo '<div class="avatar_container">' . get_avatar( $user_info->ID, apply_filters( 'sidebar_login_widget_avatar_size', 45 ) ) . '</div>';
- }
- echo '<p>';
- if($chk_show_user=='on'){
- _e('Logged in as ', 'dsslw_text_domain');
- echo '<strong>' . ucfirst( implode(', ', $user_info->roles)) . '</strong> <br>';
- }
- if($chk_show_postcount=='on'){
- _e('Posts by you','dsslw_text_domain'); echo ': '. count_user_posts( $user_info->ID ).'<br>';
- }
- echo "</p>";
- ?>
- </div>
- <ul id="<?php if($chk_show_avatar=='on') echo 'sidebar-login-links';else echo 'sidebar-login-links-left'; ?>">
- <?php if($chk_show_dash == 'on'){ ?>
- <li><a href="<?php echo admin_url() ?>"><?php _e( 'Dashboard' , 'dsslw_text_domain' )//_e( 'Dashboard' , 'default' ) ?> </a>|</li>
- <?php } ?>
- <?php if($chk_show_profile == 'on'){ ?>
- <li><a href="<?php echo admin_url() ?>profile.php"><?php _e( 'Profile' , 'dsslw_text_domain' )//_e( 'Profile' , 'tie' ) ?> </a>|</li>
- <?php } ?>
- <li><a href="<?php echo wp_logout_url($redirect); ?>"><?php _e( 'Logout' , 'dsslw_text_domain' )//_e( 'Logout' , 'tie' ) ?> </a></li>
- </ul>
- <?php
- }
- /*If user is not logged in then show login form*/
- else{
- $remember_val = ($chk_show_remember == 'on') ? true : false;
- wp_login_form(array( 'value_remember' => 0,
- 'redirect' => $redirect,
- 'label_username' => __( 'Username', 'dsslw_text_domain' ),
- 'label_password' => __( 'Password', 'dsslw_text_domain' ),
- 'remember' => $remember_val
- ));
- ?>
- <p id="reglost">
- <?php
- if ($chk_show_register == 'on') echo '<a href="' . wp_registration_url() . '" title="Register">'.__('Register', 'dsslw_text_domain').'</a>';
- if ($chk_show_register == 'on' and $chk_show_forgot == 'on')echo "| ";
- if ($chk_show_forgot == 'on') echo '<a href="' . wp_lostpassword_url($redirect) . '?sli=lost" rel="nofollow" title="Forgot Password">' . __('Forgot Password?','dsslw_text_domain') . '</a>';
- ?>
- </p>
- <?php
- }
- echo $after_widget;
- }
- if ( !empty($referrer) && !strstr($referrer,'wp-login') && !strstr($referrer,'wp-admin') ) {
- wp_redirect(home_url() . '/?login=failed&errcode='.$current_error );
- exit;
- }
- if (is_wp_error($user) && in_array($user->get_error_code(), $ignore_codes) ) {
- $current_error = $user->get_error_code();
- do_action('wp_login_failed', $username);
- }
- return $user;
- }
- <h3>Register with PLP today : </h3>
- <dl>
- <dt> <label for="ds_first_name">First Name : </label></dt>
- <dd><input type="text" name="ds_first_name" id="ds_first_name" value="" required="required" /></dd>
- <dt> <label for="ds_last_name">Second Name : </label></dt>
- <dd><input type="text" name="ds_last_name" value="" id="ds_last_name" required="required" /></dd>
- <dt><label for="ds_organization">School/Organisation : </label></dt>
- <dd><input type="text" value="" name="ds_organization" id="ds_organization" required="required" /></dd>
- <dt><label for="ds_job_title">Job Title : </label> </dt>
- <dd><input type="text" value="" name="ds_job_title" id="ds_job_title" required="required" /></dd>
- <dt> <label for="email">Contact Email Address : </label></dt>
- <dd><input id="remail" type="email" name="email" required="required" placeholder="Email as Username" /></dd>
- <dt><label for="password">Password</label></dt>
- <dd><input id="rpassword" type="password" name="password" required="required" placeholder="Password" /></dd>
- <dt><label for="password">Confirm Password</label></dt>
- <dd><input id="crpassword" type="password" name="crpassword" required="required" placeholder="Confirm Password" /></dd>
- <dt><label for="ds_telephone">Telephone Number :</label> </dt>
- <dd><input type="text" value="" min="1" name="ds_telephone" id="ds_telephone" required="required" /></dd>
- <dd class="ds_capcha"><div class="g-recaptcha" data-sitekey="6LeIfQ0TAAAAACq4ULTuYINWDa_Tjy46rAa4E2Ly"></div></dd>
- <dt class="ds_notes">Please note that all website communications will be sent through the above
- email address. Therefore where possible please avoid using generic email addresses.</dt>
- <dd>
- <input class="submit_button ds_widefat" id="rsubmit" type="submit" value="Register Now" name="submit">
- </dd>
- </dl>
- <?php wp_nonce_field( 'ajax-reg-nonce', 'rsecurity' ); ?>
- <input type="hidden" name="tfrm" id="rtfrm" value="" />
- <input type="hidden" name="adminemail" value="<?php echo get_option( 'admin_email' );?>" />
- <div class="clear"></div>
- </form>
- </div>
- <?php
- $html=ob_get_contents();
- ob_end_clean();
- return $html;
- $captcha=$_POST['g-recaptcha-response'];
- //require_once "recaptchalib.php", __FILE__ );
- require_once( plugin_dir_path( __FILE__ ) . 'recaptchalib.php');
- // Register API keys at https://www.google.com/recaptcha/admin
- $siteKey = "6LeIfQ0TAAAAACq4ULTuYINWDa_Tjy46rAa4E2Ly";
- $secret = "6LeIfQ0TAAAAALNerDz6Bol9ELW7fVFZNtCnGIAV";
- // reCAPTCHA supported 40+ languages listed here: https://developers.google.com/recaptcha/docs/language
- $lang = "en";
- // The response from reCAPTCHA
- $resp = null;
- // The error code from reCAPTCHA, if any
- $error = null;
- $reCaptcha = new ReCaptcha($secret);
- // Was there a reCAPTCHA response?
- if ($_POST["g-recaptcha-response"]) {
- $resp = $reCaptcha->verifyResponse(
- $_SERVER["REMOTE_ADDR"],
- $_POST["g-recaptcha-response"]
- );
- }
- if ($resp != null && $resp->success) {
- // First check the nonce, if it fails the function will break
- check_ajax_referer( 'ajax-reg-nonce', 'security' );
- // Nonce is checked, get the POST data and sign user on
- $name = $_POST['fname']." ".$_POST['lname'];
- $user_name = $_POST['remail'];
- $user_email = $_POST['remail'];
- $password = $_POST['password'];
- $ds_organization=$_POST['ds_organization'];
- $ds_job_title=$_POST['ds_job_title'];
- $ds_telephone=$_POST['ds_telephone'];
- $reg = array();
- $reg['display_name'] = $name;
- $reg['user_nicename'] = sanitize_text_field($name);
- $reg['first_name'] = $_POST['fname'];
- $reg['last_name'] = $_POST['lname'];
- $reg['nickname'] = sanitize_text_field($name);
- $reg['user_login'] = $_POST['remail'];
- $reg['user_pass'] = $_POST['password'];
- $reg['user_email'] = $_POST['remail'];
- $reg['role'] = 'pending';
- $user_id = username_exists( $user_name );
- if ( !$user_id and email_exists($user_email) == false ) {
- //$random_password = wp_generate_password( $length=12, $include_standard_special_chars=false );
- //$user_id = wp_create_user( $user_name, $password, $user_email );
- $user_id = wp_insert_user( $reg ) ;
- add_user_meta( $user_id, 'ds_organization', $ds_organization);
- add_user_meta( $user_id, 'ds_job_title', $ds_job_title);
- add_user_meta( $user_id, 'ds_telephone', $ds_telephone);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement