Advertisement
Guest User

Untitled

a guest
Jan 11th, 2017
141
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 19.01 KB | None | 0 0
  1. <table class="form-table">
  2. <tr>
  3. <th><label for="user_website">User website</label></th>
  4. <td>
  5. <!--<select multiple name="user_web[]">-->
  6. <?php foreach($allsites as $site):
  7. $bllogdetail = get_blog_details($site['blog_id']);
  8. $slelected = in_array($site['blog_id'], $usermeta)?"checked='checked'":"";
  9. $blogname=!empty($bllogdetail->blogname)?$bllogdetail->blogname:"Sub-Site ".$site['blog_id'];
  10. ?>
  11. <!--<option <?php //echo $slelected; ?> value="<?php //echo $site['blog_id'] ?>"><?php //echo $bllogdetail->blogname ?></option>-->
  12. <input type="checkbox" <?php echo $slelected;?> name="user_web[]" value="<?php echo $site['blog_id'] ?>" />
  13. <label><?php echo $blogname; ?></label><br />
  14. <?php endforeach; ?>
  15. <!--</select>-->
  16. <span class="description">User allowed to visit website.</span>
  17. </td>
  18. </tr>
  19. </table>
  20.  
  21. <h3>Visiblity</h3>
  22. <table class="form-table">
  23. <tr>
  24. <th><label for="Visiblity">Base</label></th>
  25. <td>
  26. <select name="visiblity">
  27. <option value="public" <?php if($visiblity=='public') { echo "selected=selected"; } ?>>Public</option>
  28. <option value="private" <?php if($visiblity=='private') { echo "selected=selected"; } ?>>Private</option>
  29. </select>
  30. </td>
  31. </tr>
  32. </table>
  33. <?php
  34.  
  35. $blogstxt=implode("",$blogs);
  36. //send email
  37. $user_info = get_userdata($userid);
  38. $name=$user_info->user_firstname."".$user_info->user_lastname;
  39. $name=trim($name)==""?$user_info->display_name:$name;
  40. $from=get_option( 'admin_email' );
  41. $sitename=get_option( 'blogname' );
  42. $to=$user_info->user_login;
  43. $sub="Your new user account details for the $sitename site";
  44. $headers = "MIME-Version: 1.0n" .
  45. "From: $sitename<$from> n" .
  46. "Content-Type: text/html; charset="" . get_settings('blog_charset') . ""n";
  47. $msg="
  48. <p align="center">
  49. <img src="http://plpcic.co.uk/wp-content/uploads/2015/03/logo_PLP.png" />
  50. </p>
  51. Dear $name,<br /><br />
  52.  
  53. function __construct(){
  54. $params = array(
  55. 'description' => 'Sidebar Login to Wordpress Account',
  56. 'name' => 'Ds Sidebar Login Widget'
  57. );
  58. //Enque Style sheet
  59. wp_enqueue_style( 'tp-sidebar-login', plugins_url( 'assets/css/ds-sidebar-login.css', __FILE__ ));
  60.  
  61. //Overriding Parent Class's constructor. 3 parameters - id,name,parameters
  62. parent::__construct('SidebarLogin', '', $params);
  63.  
  64. }
  65.  
  66. /*This method is responsible for updating the widget option form*/
  67. public function update( $new_instance, $old_instance ) {
  68. $instance = array();
  69. $instance = $old_instance;
  70. $instance['title'] = strip_tags($new_instance['title']);
  71. $instance['chk_show_avatar'] = strip_tags($new_instance['chk_show_avatar']);
  72. $instance['chk_show_user'] = strip_tags($new_instance['chk_show_user']);
  73. $instance['chk_show_remember'] = strip_tags($new_instance['chk_show_remember']);
  74. $instance['chk_show_register'] = strip_tags($new_instance['chk_show_register']);
  75. $instance['chk_show_forgot'] = strip_tags($new_instance['chk_show_forgot']);
  76. $instance['chk_show_dash'] = strip_tags($new_instance['chk_show_dash']);
  77. $instance['chk_show_profile'] = strip_tags($new_instance['chk_show_profile']);
  78. $instance['chk_show_postcount'] = strip_tags($new_instance['chk_show_postcount']);
  79. return $instance;
  80. }
  81.  
  82. /*
  83. * This function is responsible for displaying forms
  84. * This method accepts a parameter which is an array
  85. */
  86.  
  87. public function form($instance){
  88.  
  89. /*An array containing default values when the widget will be used first time*/
  90. $defaults = array(
  91. 'title' => 'Login',
  92. 'chk_show_avatar' => 'on',
  93. 'chk_show_user' => 'on',
  94. 'chk_show_remember' => 'on',
  95. 'chk_show_register' => 'on',
  96. 'chk_show_forgot' => 'on',
  97. 'chk_show_dash' => 'on',
  98. 'chk_show_postcount' => 'on',
  99. 'chk_show_profile' => 'on'
  100. );
  101.  
  102. $instance = wp_parse_args( (array) $instance, $defaults );
  103.  
  104. extract($instance, EXTR_SKIP);
  105.  
  106. ?>
  107. <!-- Text field for Title -->
  108. <p>
  109. <label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title', 'dsslw_text_domain'); ?></label>
  110. <input
  111. class="widefat"
  112. type="text"
  113. id="<?php echo $this->get_field_id('title'); ?>"
  114. name="<?php echo $this->get_field_name('title'); ?>"
  115. value="<?php if(isset($title)) echo esc_attr($title); ?>"
  116. />
  117. </p>
  118. <!-- Checkbox to turn on/off the option to display avatar -->
  119. <p>
  120. <input
  121. type="checkbox"
  122. <?php checked("$chk_show_avatar", 'on' );?>
  123. class="checkbox"
  124. id="<?php echo $this->get_field_id('chk_show_avatar'); ?>"
  125. name="<?php echo $this->get_field_name('chk_show_avatar'); ?>"
  126. />
  127. <label for="<?php echo $this->get_field_id('chk_show_avatar'); ?>"><?php _e('Show Avatar', 'dsslw_text_domain'); ?></label>
  128.  
  129. </p>
  130.  
  131. <!-- Checkbox to turn on/off the option to display Logged in user name -->
  132. <p>
  133. <input
  134. type="checkbox"
  135. <?php checked("$chk_show_user", 'on' );?>
  136. class="checkbox"
  137. id="<?php echo $this->get_field_id('chk_show_user'); ?>"
  138. name="<?php echo $this->get_field_name('chk_show_user'); ?>"
  139. />
  140. <label for="<?php echo $this->get_field_id('chk_show_user'); ?>"><?php _e('Show Logged in User name', 'dsslw_text_domain'); ?></label>
  141.  
  142. </p>
  143.  
  144. <!-- Checkbox to turn on/off the option to display Dashboard link when logged in -->
  145. <p>
  146. <input
  147. type="checkbox"
  148. <?php checked("$chk_show_dash", 'on' ); ?>
  149. class="checkbox"
  150. id="<?php echo $this->get_field_id('chk_show_dash'); ?>"
  151. name="<?php echo $this->get_field_name('chk_show_dash'); ?>"
  152. />
  153. <label for="<?php echo $this->get_field_id('chk_show_dash'); ?>"> <?php _e('Show Dashboard Link', 'dsslw_text_domain'); ?> </label>
  154.  
  155. </p>
  156.  
  157. <!-- Checkbox to turn on/off the option to display profile link when logged in -->
  158. <p>
  159. <input
  160. type="checkbox"
  161. <?php checked("$chk_show_profile", 'on' ); ?>
  162. class="checkbox"
  163. id="<?php echo $this->get_field_id('chk_show_profile'); ?>"
  164. name="<?php echo $this->get_field_name('chk_show_profile'); ?>"
  165. />
  166. <label for="<?php echo $this->get_field_id('chk_show_profile'); ?>"> <?php _e('Show Profile Link', 'dsslw_text_domain'); ?> </label>
  167.  
  168. </p>
  169.  
  170. <!-- Checkbox to turn on/off the option to display Remember me option when not logged in -->
  171. <p>
  172. <input
  173. type="checkbox"
  174. <?php checked("$chk_show_remember", 'on' ); ?>
  175. class="checkbox"
  176. id="<?php echo $this->get_field_id('chk_show_remember'); ?>"
  177. name="<?php echo $this->get_field_name('chk_show_remember'); ?>"
  178. />
  179. <label for="<?php echo $this->get_field_id('chk_show_remember'); ?>"> <?php _e('Show Remember me', 'dsslw_text_domain'); ?> </label>
  180.  
  181. </p>
  182.  
  183. <!-- Checkbox to turn on/off the option to display Register link on login form -->
  184. <p>
  185. <input
  186. type="checkbox"
  187. <?php checked("$chk_show_register", 'on' ); ?>
  188. class="checkbox"
  189. id="<?php echo $this->get_field_id('chk_show_register'); ?>"
  190. name="<?php echo $this->get_field_name('chk_show_register'); ?>"
  191. />
  192. <label for="<?php echo $this->get_field_id('chk_show_register'); ?>"> <?php _e('Show Register Link', 'dsslw_text_domain'); ?> </label>
  193.  
  194. </p>
  195.  
  196. <!-- Checkbox to turn on/off the option to display Forgot Password link on login form -->
  197. <p>
  198. <input
  199. type="checkbox"
  200. <?php checked("$chk_show_forgot", 'on' ); ?>
  201. class="checkbox"
  202. id="<?php echo $this->get_field_id('chk_show_forgot'); ?>"
  203. name="<?php echo $this->get_field_name('chk_show_forgot'); ?>"
  204. />
  205. <label for="<?php echo $this->get_field_id('chk_show_forgot'); ?>"> <?php _e('Show Forgotten Password Link', 'dsslw_text_domain'); ?> </label>
  206.  
  207. </p>
  208.  
  209. <!-- Checkbox to turn on/off the option to display Post count -->
  210. <p>
  211. <input
  212. type="checkbox"
  213. <?php checked("$chk_show_postcount", 'on' ); ?>
  214. class="checkbox"
  215. id="<?php echo $this->get_field_id('chk_show_postcount'); ?>"
  216. name="<?php echo $this->get_field_name('chk_show_postcount'); ?>"
  217. />
  218. <label for="<?php echo $this->get_field_id('chk_show_postcount'); ?>"> <?php _e('Show Post Count', 'dsslw_text_domain'); ?> </label>
  219.  
  220. </p>
  221. <?php
  222. }
  223.  
  224. /*
  225. *This method is responsible for displaying the outputs in the widgetized area
  226. */
  227.  
  228. public function widget($args, $instance){
  229. extract($args);
  230. extract($instance);
  231.  
  232. global $user_login;
  233.  
  234. // Setting default title when nothing is set from widget option
  235. if(empty($title)){
  236. $title = __("Member's Login", "dsslw_text_domain");
  237. }
  238. else{
  239. $title = apply_filters('widget_title', $title );
  240. }
  241.  
  242.  
  243. if(is_user_logged_in()){
  244. $user_info = get_user_by('login', $user_login);
  245.  
  246. $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;
  247. }
  248.  
  249. echo $before_widget;
  250. echo $before_title;
  251. echo $title;
  252. echo $after_title;
  253.  
  254. $redirect = site_url();
  255. if (isset($_GET['login'])) {
  256.  
  257. $login = $_GET['login']; // This variable is used when login failure occurs
  258. $current_error = $_GET['errcode']; // This variable is used to display the type of error during login
  259.  
  260. if ($login == 'failed'){
  261.  
  262. if ($current_error == "empty_username" || $current_error == "empty_password"){
  263. $error_msg = __('Enter both Username and Password', 'dsslw_text_domain');
  264. }
  265. elseif($current_error == 'invalid_username'){
  266. $error_msg = __('Username is not registered', 'dsslw_text_domain');
  267. }
  268. elseif($current_error == 'incorrect_password'){
  269. $error_msg = __('Incorrect Password', 'dsslw_text_domain');
  270. }
  271.  
  272. echo "<div id='message' class='error fade'><p><strong>".$error_msg."</strong></p></div>";
  273.  
  274. }
  275.  
  276. }
  277. /*Check if user is logged in then show user information and logout,dashboardand profile link*/
  278. if (is_user_logged_in()) {
  279.  
  280. ?>
  281. <div class="sidebar-login-info">
  282. <?php
  283.  
  284. if ($chk_show_avatar == "on"){
  285. $show_avatar = isset( $show_avatar ) ? $show_avatar : 1;
  286. if ( $show_avatar == 1 )
  287. echo '<div class="avatar_container">' . get_avatar( $user_info->ID, apply_filters( 'sidebar_login_widget_avatar_size', 45 ) ) . '</div>';
  288. }
  289. echo '<p>';
  290. if($chk_show_user=='on'){
  291. _e('Logged in as ', 'dsslw_text_domain');
  292. echo '<strong>' . ucfirst( implode(', ', $user_info->roles)) . '</strong> <br>';
  293. }
  294. if($chk_show_postcount=='on'){
  295. _e('Posts by you','dsslw_text_domain'); echo ': '. count_user_posts( $user_info->ID ).'<br>';
  296. }
  297. echo "</p>";
  298. ?>
  299. </div>
  300.  
  301. <ul id="<?php if($chk_show_avatar=='on') echo 'sidebar-login-links';else echo 'sidebar-login-links-left'; ?>">
  302.  
  303. <?php if($chk_show_dash == 'on'){ ?>
  304. <li><a href="<?php echo admin_url() ?>"><?php _e( 'Dashboard' , 'dsslw_text_domain' )//_e( 'Dashboard' , 'default' ) ?> </a>|</li>
  305. <?php } ?>
  306. <?php if($chk_show_profile == 'on'){ ?>
  307. <li><a href="<?php echo admin_url() ?>profile.php"><?php _e( 'Profile' , 'dsslw_text_domain' )//_e( 'Profile' , 'tie' ) ?> </a>|</li>
  308. <?php } ?>
  309. <li><a href="<?php echo wp_logout_url($redirect); ?>"><?php _e( 'Logout' , 'dsslw_text_domain' )//_e( 'Logout' , 'tie' ) ?> </a></li>
  310.  
  311. </ul>
  312.  
  313. <?php
  314. }
  315. /*If user is not logged in then show login form*/
  316. else{
  317. $remember_val = ($chk_show_remember == 'on') ? true : false;
  318.  
  319. wp_login_form(array( 'value_remember' => 0,
  320. 'redirect' => $redirect,
  321. 'label_username' => __( 'Username', 'dsslw_text_domain' ),
  322. 'label_password' => __( 'Password', 'dsslw_text_domain' ),
  323. 'remember' => $remember_val
  324. ));
  325. ?>
  326. <p id="reglost">
  327. <?php
  328. if ($chk_show_register == 'on') echo '<a href="' . wp_registration_url() . '" title="Register">'.__('Register', 'dsslw_text_domain').'</a>';
  329. if ($chk_show_register == 'on' and $chk_show_forgot == 'on')echo "| ";
  330. 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>';
  331. ?>
  332. </p>
  333. <?php
  334. }
  335. echo $after_widget;
  336. }
  337.  
  338. if ( !empty($referrer) && !strstr($referrer,'wp-login') && !strstr($referrer,'wp-admin') ) {
  339. wp_redirect(home_url() . '/?login=failed&errcode='.$current_error );
  340. exit;
  341. }
  342.  
  343. if (is_wp_error($user) && in_array($user->get_error_code(), $ignore_codes) ) {
  344. $current_error = $user->get_error_code();
  345. do_action('wp_login_failed', $username);
  346. }
  347. return $user;
  348. }
  349.  
  350. <h3>Register with PLP today : </h3>
  351. <dl>
  352. <dt> <label for="ds_first_name">First Name : </label></dt>
  353. <dd><input type="text" name="ds_first_name" id="ds_first_name" value="" required="required" /></dd>
  354. <dt> <label for="ds_last_name">Second Name : </label></dt>
  355. <dd><input type="text" name="ds_last_name" value="" id="ds_last_name" required="required" /></dd>
  356. <dt><label for="ds_organization">School/Organisation : </label></dt>
  357. <dd><input type="text" value="" name="ds_organization" id="ds_organization" required="required" /></dd>
  358. <dt><label for="ds_job_title">Job Title : </label> </dt>
  359. <dd><input type="text" value="" name="ds_job_title" id="ds_job_title" required="required" /></dd>
  360. <dt> <label for="email">Contact Email Address : </label></dt>
  361. <dd><input id="remail" type="email" name="email" required="required" placeholder="Email as Username" /></dd>
  362. <dt><label for="password">Password</label></dt>
  363. <dd><input id="rpassword" type="password" name="password" required="required" placeholder="Password" /></dd>
  364. <dt><label for="password">Confirm Password</label></dt>
  365. <dd><input id="crpassword" type="password" name="crpassword" required="required" placeholder="Confirm Password" /></dd>
  366. <dt><label for="ds_telephone">Telephone Number :</label> </dt>
  367. <dd><input type="text" value="" min="1" name="ds_telephone" id="ds_telephone" required="required" /></dd>
  368. <dd class="ds_capcha"><div class="g-recaptcha" data-sitekey="6LeIfQ0TAAAAACq4ULTuYINWDa_Tjy46rAa4E2Ly"></div></dd>
  369. <dt class="ds_notes">Please note that all website communications will be sent through the above
  370. email address. Therefore where possible please avoid using generic email addresses.</dt>
  371. <dd>
  372. <input class="submit_button ds_widefat" id="rsubmit" type="submit" value="Register Now" name="submit">
  373. </dd>
  374.  
  375. </dl>
  376. <?php wp_nonce_field( 'ajax-reg-nonce', 'rsecurity' ); ?>
  377. <input type="hidden" name="tfrm" id="rtfrm" value="" />
  378. <input type="hidden" name="adminemail" value="<?php echo get_option( 'admin_email' );?>" />
  379. <div class="clear"></div>
  380. </form>
  381.  
  382.  
  383. </div>
  384.  
  385. <?php
  386. $html=ob_get_contents();
  387.  
  388. ob_end_clean();
  389. return $html;
  390.  
  391. $captcha=$_POST['g-recaptcha-response'];
  392. //require_once "recaptchalib.php", __FILE__ );
  393.  
  394. require_once( plugin_dir_path( __FILE__ ) . 'recaptchalib.php');
  395. // Register API keys at https://www.google.com/recaptcha/admin
  396. $siteKey = "6LeIfQ0TAAAAACq4ULTuYINWDa_Tjy46rAa4E2Ly";
  397. $secret = "6LeIfQ0TAAAAALNerDz6Bol9ELW7fVFZNtCnGIAV";
  398. // reCAPTCHA supported 40+ languages listed here: https://developers.google.com/recaptcha/docs/language
  399. $lang = "en";
  400. // The response from reCAPTCHA
  401. $resp = null;
  402. // The error code from reCAPTCHA, if any
  403. $error = null;
  404. $reCaptcha = new ReCaptcha($secret);
  405. // Was there a reCAPTCHA response?
  406. if ($_POST["g-recaptcha-response"]) {
  407. $resp = $reCaptcha->verifyResponse(
  408. $_SERVER["REMOTE_ADDR"],
  409. $_POST["g-recaptcha-response"]
  410. );
  411. }
  412.  
  413. if ($resp != null && $resp->success) {
  414. // First check the nonce, if it fails the function will break
  415. check_ajax_referer( 'ajax-reg-nonce', 'security' );
  416. // Nonce is checked, get the POST data and sign user on
  417. $name = $_POST['fname']." ".$_POST['lname'];
  418. $user_name = $_POST['remail'];
  419. $user_email = $_POST['remail'];
  420. $password = $_POST['password'];
  421.  
  422.  
  423. $ds_organization=$_POST['ds_organization'];
  424. $ds_job_title=$_POST['ds_job_title'];
  425. $ds_telephone=$_POST['ds_telephone'];
  426.  
  427. $reg = array();
  428. $reg['display_name'] = $name;
  429. $reg['user_nicename'] = sanitize_text_field($name);
  430. $reg['first_name'] = $_POST['fname'];
  431. $reg['last_name'] = $_POST['lname'];
  432. $reg['nickname'] = sanitize_text_field($name);
  433. $reg['user_login'] = $_POST['remail'];
  434. $reg['user_pass'] = $_POST['password'];
  435. $reg['user_email'] = $_POST['remail'];
  436.  
  437.  
  438.  
  439. $reg['role'] = 'pending';
  440.  
  441. $user_id = username_exists( $user_name );
  442. if ( !$user_id and email_exists($user_email) == false ) {
  443. //$random_password = wp_generate_password( $length=12, $include_standard_special_chars=false );
  444. //$user_id = wp_create_user( $user_name, $password, $user_email );
  445. $user_id = wp_insert_user( $reg ) ;
  446. add_user_meta( $user_id, 'ds_organization', $ds_organization);
  447. add_user_meta( $user_id, 'ds_job_title', $ds_job_title);
  448. add_user_meta( $user_id, 'ds_telephone', $ds_telephone);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement