Guest User

Untitled

a guest
Dec 10th, 2017
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.41 KB | None | 0 0
  1. function createNewAccount( $args ) {
  2. $this->escape( $args );
  3.  
  4. $username = $args[0];
  5. $password = $args[1];
  6.  
  7. $new_username = $args[2];
  8. $new_user_psswd = $args[3];
  9. $email = $args[4];
  10. $weblog_title = $args[5];
  11. $domain = $args[6];
  12. $bio = $args[7];
  13. $aeUrl = $args[8];
  14.  
  15. if ( !$user = $this->login($username, $password) ) {
  16. return $this->error;
  17. }
  18.  
  19. if ( !current_user_can( 'manage_options' ) ) {
  20. return new IXR_Error( 403, __( 'You are not allowed access to details about this blog.' ) );
  21. }
  22.  
  23. try {
  24. do_action('xmlrpc_call', 'dgr.createNewAccount');
  25. } catch (Exception $e) {
  26. return new IXR_Error(9876, __('Error creating account'));
  27. }
  28.  
  29. $user_id = 0;
  30.  
  31. try {
  32. $user_id = wpmu_create_user($new_username, $new_user_psswd, $email);
  33. } catch (Exception $e) {
  34. return new IXR_Error(9876, __('Error during user creation user_id ='.$user_id.' error : '.$e));
  35. }
  36.  
  37.  
  38. if ( $user_id < 1) {
  39. return new IXR_Error(9876, __('Failed to create the user. '.$user_id));
  40. }
  41. else
  42. {
  43. try {
  44. //create the user bio
  45. wp_update_user( array ('ID' => $user_id, 'description' => $bio, 'user_url' => $aeUrl) ) ;
  46. } catch (Exception $e) {
  47. return new IXR_Error(9876, __('Error updating bio user_id ='.$user_id.' error : '.$e));
  48. }
  49. }
  50.  
  51. try {
  52. $blog_id = wpmu_create_blog($domain, '/', $weblog_title, $user_id );
  53. } catch (Exception $e) {
  54. return new IXR_Error(9876, __('Error during blog creation blog_id ='.$blog_id.' error : '.$e));
  55. }
  56.  
  57. return $blog_id;
  58. }
  59.  
  60. function updateUserMeta( $args ) {
  61. $this->escape( $args );
  62.  
  63. $username = $args[0];
  64. $password = $args[1];
  65.  
  66. $bio = $args[2];
  67. $aeUrl = $args[3];
  68.  
  69. if ( ! $user = $this->login($username, $password)) {
  70. return $this->error;
  71. }
  72.  
  73. if ( ! current_user_can('manage_options'))
  74. return new IXR_Error(403, __('You are not allowed access to details about this blog.'));
  75.  
  76. //create the user bio
  77.  
  78. $user_id = $user->ID;
  79. try {
  80. $id_of_updated_user = wp_update_user(array ('ID' => $user_id, 'description' => $bio, 'user_url' => $aeUrl));
  81. } catch (Exception $e) {
  82. return new IXR_Error(9876, __('Error updating user details for user_id ='.$user_id.' error : '.$e));
  83. }
  84.  
  85. if ( ! $id_of_updated_user) {
  86. return new IXR_Error(9876, __('Error updating user details for user_id ='.$user_id));
  87. }
  88.  
  89. return $id_of_updated_user;
  90. }
Add Comment
Please, Sign In to add comment