function update_profile($errors, $update, $user) { if ($errors->get_error_code()) { return; } if (!empty($_POST['pass1'])) { // Check if we need to set a timestamp $expirationperiod = shrkey_get_option('_shrkey_expirepassword_expirationperiod', 0); if ($expirationperiod > 0) { // We have a period - set the stamp update_user_meta($user->ID, '_shrkey_password_expiration_start', time()); } } }
function show_options_page() { $messages = array(); $messages[1] = __('Settings updated.', 'expirepassword'); $messages[2] = __('Settings could not be updated.', 'expirepassword'); ?> <div class="wrap"> <div class="icon32" id="icon-options-general"><br></div> <h2><?php _e('Expire Password Settings', 'expirepassword'); ?> </h2> <?php if (isset($_GET['msg'])) { echo '<div id="message" class="updated fade"><p>' . $messages[(int) $_GET['msg']] . '</p></div>'; $_SERVER['REQUEST_URI'] = remove_query_arg(array('msg'), $_SERVER['REQUEST_URI']); } ?> <form action="?page=<?php echo esc_attr($_GET['page']); ?> " method="post"> <input type='hidden' name='action' value='updateexpirepassword' /> <?php wp_original_referer_field(true, 'previous'); wp_nonce_field('update-expirespasswordsettings'); if (is_network_admin()) { // Add in network admin specific options here ?> <h3><?php _e('Restrict Settings Access', 'expirepassword'); ?> </h3> <table class="form-table"> <tbody> <tr valign="top"> <th scope="row"> <label for="expirepassword_limittonetworkadmin"><?php _e('Limit Settings to Network Admin', 'expirepassword'); ?> </label> </th> <td> <?php $limittonetworkadmin = get_site_option('_shrkey_limit_expirepasswords_to_networkadmin', 'no'); ?> <select name='expirepassword_limittonetworkadmin'> <option value='no' <?php selected('no', $limittonetworkadmin); ?> ><?php _e('No, thanks', 'expirepassword'); ?> </option> <option value='yes' <?php selected('yes', $limittonetworkadmin); ?> ><?php _e('Yes, please', 'expirepassword'); ?> </option> </select> <br> <?php _e('Set this to <strong>Yes, please</strong> if you do not want individual site admin pages.', 'expirepassword'); ?> </td> </tr> </tbody> </table> <?php } ?> <h3><?php _e('Registration Settings', 'expirepassword'); ?> </h3> <p><?php _e('You can use this option to force a new user to change their password from the system generated one when they first sign in.', 'expirepassword'); ?> </p> <table class="form-table"> <tbody> <tr valign="top"> <th scope="row"> <label for="expirepassword_expireimmediately"><?php _e('Force change on first sign in', 'expirepassword'); ?> </label> </th> <td> <?php $expireimmediately = shrkey_get_option('_shrkey_expirepassword_expireimmediately', 'no'); ?> <select name='expirepassword_expireimmediately'> <option value='no' <?php selected('no', $expireimmediately); ?> ><?php _e('No, thanks', 'expirepassword'); ?> </option> <option value='yes' <?php selected('yes', $expireimmediately); ?> ><?php _e('Yes, please', 'expirepassword'); ?> </option> </select> </td> </tr> </tbody> </table> <h3><?php _e('Automatic Expiration Settings', 'expirepassword'); ?> </h3> <p><?php _e('You can set passwords to automatically expire after a set period of time. The expiration timer for a user will start the next time the user logs in to the site.', 'expirepassword'); ?> </p> <table class="form-table"> <tbody> <tr valign="top"> <th scope="row"> <label for="expirepassword_expirationperiod"><?php _e('Expiration period', 'expirepassword'); ?> </label> </th> <td> <?php $expirationperiod = shrkey_get_option('_shrkey_expirepassword_expirationperiod', 0); ?> <select name='expirepassword_expirationperiod'> <?php for ($n = 0; $n <= (int) EXPIREPASSWORD_MAXIMUM_PERIOD; $n++) { switch ($n) { case 0: ?> <option value='<?php echo $n; ?> ' <?php selected($n, $expirationperiod); ?> ><?php _e('No automatic expiration', 'expirepassword'); ?> </option> <?php break; case 1: ?> <option value='<?php echo $n; ?> ' <?php selected($n, $expirationperiod); ?> ><?php echo sprintf(__('%d day', 'expirepassword'), $n); ?> </option> <?php break; default: ?> <option value='<?php echo $n; ?> ' <?php selected($n, $expirationperiod); ?> ><?php echo sprintf(__('%d days', 'expirepassword'), $n); ?> </option> <?php break; } } ?> </select> </td> </tr> </tbody> </table> <h3><?php _e('Post Password Change Settings', 'expirepassword'); ?> </h3> <p><?php _e('Once a password has been changed, you can either force the user to login again with the new details, or complete the authentication process and log them in automatically.', 'expirepassword'); ?> </p> <table class="form-table"> <tbody> <tr valign="top"> <th scope="row"> <label for="expirepassword_autoauthenticate"><?php _e('Force Re-Login', 'expirepassword'); ?> </label> </th> <td> <?php $autoauthenticate = shrkey_get_option('_shrkey_expirepassword_autoauthenticate', 'no'); ?> <select name='expirepassword_autoauthenticate'> <option value='yes' <?php selected('yes', $expireimmediately); ?> ><?php _e('No, let the user carry on to their destination', 'expirepassword'); ?> </option> <option value='no' <?php selected('no', $expireimmediately); ?> ><?php _e('Yes, send the user to the login page', 'expirepassword'); ?> </option> </select> </td> </tr> </tbody> </table> <p class="submit"> <input type="submit" value="<?php _e('Save Changes', 'expirepassword'); ?> " class="button button-primary" id="submit" name="submit"> </p> </form> </div> <?php }