admin_edit.php 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. <?php
  2. //This file is used to edit member's profile from the admin dashboard of the plugin.
  3. //The admin ajax causes an issue with the JS validation if done on form submission. The edit profile doesn't need JS validation on email. There is PHP validation which will catch any email error.
  4. //SimpleWpMembership::enqueue_validation_scripts(array('ajaxEmailCall' => array('extraData'=>'&action=swpm_validate_email&member_id='.$member_id)));
  5. ?>
  6. <div class="wrap" id="swpm-profile-page" type="edit">
  7. <form action="" method="post" name="swpm-edit-user" id="swpm-edit-user" enctype="multipart/form-data" class="validate swpm-validate-form"<?php do_action('user_new_form_tag');?>>
  8. <input name="action" type="hidden" value="edituser" />
  9. <?php wp_nonce_field( 'edit_swpmuser_admin_end', '_wpnonce_edit_swpmuser_admin_end' ) ?>
  10. <h3><?php echo SwpmUtils::_('Edit Member') ?></h3>
  11. <p>
  12. <?php echo SwpmUtils::_('Edit existing member details.'); ?>
  13. <?php echo SwpmUtils::_(' You are currenty editing member with member ID: '); ?>
  14. <?php echo esc_attr($member_id); ?>
  15. </p>
  16. <table class="form-table">
  17. <tr class="form-field form-required swpm-admin-edit-username">
  18. <th scope="row"><label for="user_name"><?php echo SwpmUtils::_('Username'); ?> <span class="description"><?php echo SwpmUtils::_('(required)'); ?></span></label></th>
  19. <td>
  20. <?php
  21. if (empty($user_name)) {
  22. //This is a record with incomplete registration. The member need to complete the registration by clicking on the unique link sent to them
  23. ?>
  24. <div class="swpm-yellow-box" style="max-width:450px;">
  25. <p>This user account registration is not complete yet. The member needs to click on the unique registration completion link (sent to his email) and complete the registration by choosing a username and password.</p>
  26. <br />
  27. <p>You can go to the <a href="admin.php?page=simple_wp_membership_settings&tab=4" target="_blank">Tools Interface</a> and generate another unique "Registration Completion" link then send the link to the user. Alternatively, you can use that link yourself and complete the registration on behalf of the user.</p>
  28. <br />
  29. <p>If you suspect that this user has lost interest in becoming a member then you can delete this member record.</p>
  30. </div>
  31. <?php
  32. } else {
  33. echo esc_attr($user_name);
  34. }
  35. ?>
  36. </td>
  37. </tr>
  38. <tr class="form-required swpm-admin-edit-email">
  39. <th scope="row"><label for="email"><?php echo SwpmUtils::_('E-mail'); ?> <span class="description"><?php echo SwpmUtils::_('(required)'); ?></span></label></th>
  40. <td><input name="email" autocomplete="off" class="regular-text validate[required,custom[email],ajax[ajaxEmailCall]]" type="text" id="email" value="<?php echo esc_attr($email); ?>" /></td>
  41. </tr>
  42. <tr class="swpm-admin-edit-password">
  43. <th scope="row"><label for="password"><?php echo SwpmUtils::_('Password'); ?> <span class="description"><?php _e('(twice, leave empty to retain old password)', 'simple-membership'); ?></span></label></th>
  44. <td><input class="regular-text" name="password" type="password" id="pass1" autocomplete="off" /><br />
  45. <input class="regular-text" name="password_re" type="password" id="pass2" autocomplete="off" />
  46. <br />
  47. <div id="pass-strength-result"><?php echo SwpmUtils::_('Strength indicator'); ?></div>
  48. <p class="description indicator-hint"><?php echo SwpmUtils::_('Hint: The password should be at least seven characters long. To make it stronger, use upper and lower case letters, numbers and symbols like ! " ? $ % ^ &amp; ).'); ?></p>
  49. </td>
  50. </tr>
  51. <tr class="swpm-admin-edit-account-state">
  52. <th scope="row"><label for="account_state"><?php echo SwpmUtils::_('Account Status'); ?></label></th>
  53. <td>
  54. <select class="regular-text" name="account_state" id="account_state">
  55. <?php echo SwpmUtils::account_state_dropdown($account_state);?>
  56. </select>
  57. <p class="description">
  58. <?php echo SwpmUtils::_("This is the member's account status. If you want to manually activate an expired member's account then read"); ?>
  59. <a href="https://simple-membership-plugin.com/manually-activating-expired-members-account/" target="_blank"><?php echo SwpmUtils::_("this documentation"); ?></a>
  60. <?php echo SwpmUtils::_(" to learn how to do it."); ?>
  61. </p>
  62. </td>
  63. </tr>
  64. <tr class="swpm-admin-edit-notify-user">
  65. <th scope="row"><label for="account_state_change"><?php echo SwpmUtils::_('Notify User'); ?></label></th>
  66. <td><input type="checkbox" id="account_status_change" name="account_status_change" />
  67. <p class="description indicator-hint">
  68. <?php echo SwpmUtils::_("You can use this option to send a quick notification email to this member (the email will be sent when you hit the save button below)."); ?>
  69. </p>
  70. </td>
  71. </tr>
  72. <?php include('admin_member_form_common_part.php');?>
  73. <tr class="swpm-admin-edit-subscriber-id">
  74. <th scope="row"><label for="subscr_id"><?php echo SwpmUtils::_('Subscriber ID/Reference') ?> </label></th>
  75. <td><input class="regular-text" name="subscr_id" type="text" id="subscr_id" value="<?php echo esc_attr($subscr_id); ?>" /></td>
  76. </tr>
  77. <tr class="swpm-admin-edit-expiry-date">
  78. <th scope="row"><label for="member_expiry_date"><?php echo SwpmUtils::_('Expiry Date') ?> </label></th>
  79. <td>
  80. <?php
  81. $member_current_expiry_date = SwpmMemberUtils::get_formatted_expiry_date_by_user_id($member_id);
  82. echo esc_attr($member_current_expiry_date);
  83. ?>
  84. <p class="description indicator-hint">
  85. <?php echo SwpmUtils::_('This is calculated based on the current membership level assigned to this member and the expiry condition that you have set for that membership level.') ?>
  86. </p>
  87. </td>
  88. </tr>
  89. <tr class="swpm-admin-edit-last-accessed">
  90. <th scope="row"><label for="last_accessed"><?php echo SwpmUtils::_('Last Accessed Date') ?> </label></th>
  91. <td>
  92. <?php echo esc_attr($last_accessed); ?>
  93. <p class="description indicator-hint"><?php echo SwpmUtils::_('This value gets updated when this member logs into your site.') ?></p>
  94. </td>
  95. </tr>
  96. <tr class="swpm-admin-edit-last-accessed-ip">
  97. <th scope="row"><label for="last_accessed_from_ip"><?php echo SwpmUtils::_('Last Accessed From IP') ?> </label></th>
  98. <td>
  99. <?php echo esc_attr($last_accessed_from_ip); ?>
  100. <p class="description indicator-hint"><?php echo SwpmUtils::_('This value gets updated when this member logs into your site.') ?></p>
  101. </td>
  102. </tr>
  103. </table>
  104. <?php include('admin_member_form_common_js.php'); ?>
  105. <?php echo apply_filters('swpm_admin_custom_fields', '',$membership_level); ?>
  106. <?php submit_button( SwpmUtils::_('Save Data'), 'primary', 'editswpmuser', true, array( 'id' => 'createswpmusersub' ) ); ?>
  107. <?php
  108. $delete_swpmuser_nonce = wp_create_nonce( 'delete_swpmuser_admin_end' );
  109. $member_delete_url = "?page=simple_wp_membership&member_action=delete&member_id=".$member_id."&delete_swpmuser_nonce=".$delete_swpmuser_nonce;
  110. echo '<div class="swpm-admin-delete-user-profile-link">';
  111. echo '<a style="color:red;font-weight:bold;" href="'.$member_delete_url.'" onclick="return confirm(\'Are you sure you want to delete this user profile?\')">'.SwpmUtils::_('Delete User Profile').'</a>';
  112. echo '</div>';
  113. ?>
  114. </form>
  115. </div>
  116. <script>
  117. jQuery(document).ready(function($){
  118. $('#account_status_change').change(function(){
  119. var target = $(this).closest('tr');
  120. var $body = '<textarea rows="5" cols="60" id="notificationmailbody" name="notificationmailbody">' + SwpmSettings.statusChangeEmailBody + '</textarea>';
  121. var $head = '<input type="text" size="60" id="notificationmailhead" name="notificationmailhead" value="' + SwpmSettings.statusChangeEmailHead + '" />';
  122. var content = '<tr><th scope="row">Mail Subject</th><td>' + $head + '</td></tr>';
  123. content += '<tr><th scope="row">Mail Body</th><td>' + $body + '</td></tr>';
  124. if (this.checked) {
  125. target.after(content);
  126. }
  127. else {
  128. if (target.next('tr').find('#notificationmailhead').length > 0) {
  129. target.next('tr').remove();
  130. target.next('tr').remove();
  131. }
  132. }
  133. });
  134. });
  135. </script>