Advertisement
Guest User

Untitled

a guest
Sep 4th, 2017
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.92 KB | None | 0 0
  1. function myprefix_edit_user_cb(){
  2. $user_id=$_REQUEST['user_id'];
  3.  
  4. $user = get_user_by( 'ID', $user_id );
  5.  
  6. echo
  7. ' <fieldset>
  8. <legend>Form</legend>
  9. <form id="update-form" action="" method="POST">
  10. <label>Username:<span style="color:red">*</span></label>
  11.  
  12. <input name="id" type="hidden" value=" '. $user->ID.' " required>
  13. <input name="username" type="text" value=" '. $user->user_login.' " required>
  14. <label>Email:<span style="color:red">*</span></label>
  15. <input name="email" type="email" value="'.$user->user_email.'" required>
  16. <label>Password:</label>
  17. <input name="password" type="password" value="">
  18. <input class="btn btn-default" name="submit" type="submit" value="submit">
  19. </form>
  20. </fieldset>
  21. ';
  22.  
  23. die();
  24. }
  25.  
  26. function update_data()
  27. {
  28.  
  29. wp_enqueue_style('mysample');
  30.  
  31. global $reg_errors;
  32.  
  33. if(isset($_POST['submit']))
  34. {
  35.  
  36. $username=isset($_POST['username'])?$_POST['username']:null;
  37. $email=isset($_POST['email'])?$_POST['email']:null;
  38. $password=isset($_POST['password'])?$_POST['password']:null;
  39.  
  40. validation_for_edit($username,$email,$password);
  41.  
  42. $userdata = array(
  43.  
  44. 'ID' => $_POST['id'],
  45. 'user_login' => $username,
  46. 'user_email' => $email,
  47. 'user_pass' => $password,
  48. );
  49.  
  50. echo "<pre>";print_r($userdata);
  51.  
  52. if(1 > count( $reg_errors->get_error_messages() ) )
  53. {
  54. if($userdata=wp_update_user( $userdata ))
  55. {
  56. echo '<span id="message">Update complete.</span>';
  57. echo 'Goto <a href="' . get_site_url() . '/wp-login.php">login page</a>';
  58. }
  59. }
  60. }
  61. die();
  62. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement