Plugin Directory

Changeset 1525710


Ignore:
Timestamp:
11/01/2016 03:24:05 AM (9 years ago)
Author:
picklewagon
Message:

New User Approve version 1.7.4

Location:
new-user-approve/trunk
Files:
1 added
2 deleted
4 edited

Legend:

Unmodified
Added
Removed
  • new-user-approve/trunk/includes/email-tags.php

    r997107 r1525710  
    267267            'context'     => array( 'email' ),
    268268        ),
     269        array(
     270            'tag'         => 'reset_password_url',
     271            'description' => __( 'The URL for a user to set/reset their password', 'new-user-approve' ),
     272            'function'    => 'nua_email_tag_reset_password_url',
     273            'context'     => array( 'email' ),
     274        ),
    269275        array(
    270276            'tag'         => 'password',
     
    393399    }
    394400}
     401
     402/**
     403 * Email template tag: reset_password_url
     404 * Generates a link to set or reset the user's password
     405 *
     406 * @param array $attributes
     407 *
     408 * @return string reset password URL
     409 */
     410function nua_email_tag_reset_password_url( $attributes ) {
     411    global $wpdb;
     412
     413    $username = $attributes['user_login'];
     414
     415    // Generate something random for a password reset key.
     416    $key = wp_generate_password( 20, false );
     417
     418    /** This action is documented in wp-login.php */
     419    do_action( 'retrieve_password_key', $username, $key );
     420
     421    // Now insert the key, hashed, into the DB.
     422    if ( empty( $wp_hasher ) ) {
     423        require_once ABSPATH . WPINC . '/class-phpass.php';
     424        $wp_hasher = new PasswordHash( 8, true );
     425    }
     426    $hashed = time() . ':' . $wp_hasher->HashPassword( $key );
     427    $wpdb->update( $wpdb->users, array( 'user_activation_key' => $hashed ), array( 'user_login' => $username ) );
     428
     429    $url = network_site_url("wp-login.php?action=rp&key=$key&login=" . rawurlencode($username), 'login');
     430
     431    return $url;
     432}
  • new-user-approve/trunk/includes/messages.php

    r997107 r1525710  
    88function nua_default_approve_user_message() {
    99    $message = __( 'You have been approved to access {sitename}', 'new-user-approve' ) . "\r\n\r\n";
    10     $message .= "{username}\r\n";
    11     $message .= "{password}\r\n\r\n";
    12     $message .= "{login_url}";
     10    $message .= "{username}\r\n\r\n";
     11    $message .= "{login_url}\r\n\r\n";
     12    $message .= __( 'To set or reset your password, visit the following address:', 'new-user-approve' ) . "\r\n\r\n";
     13    $message .= "{reset_password_url}";
    1314
    1415    $message = apply_filters( 'new_user_approve_approve_user_message_default', $message );
  • new-user-approve/trunk/includes/user-list.php

    r1057335 r1525710  
    2525        // Actions
    2626        add_action( 'load-users.php', array( $this, 'update_action' ) );
    27         add_action( 'restrict_manage_users', array( $this, 'status_filter' ) );
     27        add_action( 'restrict_manage_users', array( $this, 'status_filter' ), 10, 1 );
    2828        add_action( 'pre_user_query', array( $this, 'filter_by_status' ) );
    2929        add_action( 'admin_footer-users.php', array( $this, 'admin_footer' ) );
     
    162162     * @uses restrict_manage_users
    163163     */
    164     public function status_filter() {
     164    public function status_filter( $which ) {
     165        $id = 'new_user_approve_filter-' . $which;
     166
    165167        $filter_button = submit_button( __( 'Filter', 'new-user-approve' ), 'button', 'pw-status-query-submit', false, array( 'id' => 'pw-status-query-submit' ) );
    166         $filtered_status = ( isset( $_GET['new_user_approve_filter'] ) ) ? esc_attr( $_GET['new_user_approve_filter'] ) : '';
     168        $filtered_status = $this->selected_status();
    167169
    168170        ?>
    169         <label class="screen-reader-text"
    170                for="new_user_approve_filter"><?php _e( 'View all users', 'new-user-approve' ); ?></label>
    171         <select id="new_user_approve_filter" name="new_user_approve_filter" style="float: none; margin: 0 0 0 15px;">
     171        <label class="screen-reader-text" for="<?php echo $id ?>"><?php _e( 'View all users', 'new-user-approve' ); ?></label>
     172        <select id="<?php echo $id ?>" name="<?php echo $id ?>" style="float: none; margin: 0 0 0 15px;">
    172173            <option value=""><?php _e( 'View all users', 'new-user-approve' ); ?></option>
    173             <?php foreach ( pw_new_user_approve()->get_valid_statuses() as $status ) : ?>
    174                 <option
    175                     value="<?php echo esc_attr( $status ); ?>"<?php selected( $status, $filtered_status ); ?>><?php echo esc_html( $status ); ?></option>
    176             <?php endforeach; ?>
     174        <?php foreach ( pw_new_user_approve()->get_user_statuses() as $status => $users ) : ?>
     175            <?php if ( count( $users ) ) : ?>
     176            <option value="<?php echo esc_attr( $status ); ?>"<?php selected( $status, $filtered_status ); ?>><?php echo esc_html( $status ); ?></option>
     177            <?php endif; ?>
     178        <?php endforeach; ?>
    177179        </select>
    178180        <?php echo apply_filters( 'new_user_approve_filter_button', $filter_button ); ?>
     
    204206        }
    205207
    206         if ( isset( $_GET['new_user_approve_filter'] ) && $_GET['new_user_approve_filter'] != '' ) {
    207             $filter = esc_attr( $_GET['new_user_approve_filter'] );
    208 
    209             $query->query_from .= " INNER JOIN {$wpdb->usermeta} wp_usermeta ON ( {$wpdb->users}.ID = wp_usermeta.user_id )";
     208        if ( $this->selected_status() != null ) {
     209            $filter = $this->selected_status();
     210
     211            $query->query_from .= " INNER JOIN {$wpdb->usermeta} ON ( {$wpdb->users}.ID = wp_usermeta.user_id )";
    210212
    211213            if ( 'approved' == $filter ) {
     
    219221    }
    220222
     223    private function selected_status() {
     224        if ( ! empty( $_REQUEST['new_user_approve_filter-top'] ) || ! empty( $_REQUEST['new_user_approve_filter-bottom'] ) ) {
     225            return esc_attr( ( ! empty( $_REQUEST['new_user_approve_filter-top'] ) ) ? $_REQUEST['new_user_approve_filter-top'] : $_REQUEST['new_user_approve_filter-bottom'] );
     226        }
     227
     228        return null;
     229    }
     230
    221231    /**
    222232     * Use javascript to add the ability to bulk modify the status of users.
     
    271281            }
    272282
    273             $sendback = remove_query_arg( array( 'approved', 'denied', 'deleted', 'ids', 'new_user_approve_filter', 'pw-status-query-submit', 'new_role' ), wp_get_referer() );
     283            $sendback = remove_query_arg( array( 'approved', 'denied', 'deleted', 'ids', 'new_user_approve_filter', 'new_user_approve_filter2', 'pw-status-query-submit', 'new_role' ), wp_get_referer() );
    274284            if ( !$sendback ) {
    275285                $sendback = admin_url( 'users.php' );
  • new-user-approve/trunk/readme.txt

    r1252433 r1525710  
    1 === Plugin Name ===
     1=== New User Approve ===
    22Contributors: picklewagon
    33Donate link: http://picklewagon.com/wordpress/new-user-approve/donate
    44Tags: users, registration, sign up, user management, login
    55Requires at least: 3.5.1
    6 Tested up to: 4.3.1
    7 Stable tag: 1.7.3
     6Tested up to: 4.6.1
     7Stable tag: 1.7.4
    88License: GPLv2 or later
    99License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    1515
    1616On a normal WordPress site, once a new user registers, the user is created in
    17 the database. Then an email is sent to the new user with their login 
     17the database. Then an email is sent to the new user with their login
    1818credentials. Very simple. As it should be.
    1919
    20 The New User Approve plugin modifies the registration process. When a user 
     20The New User Approve plugin modifies the registration process. When a user
    2121registers for the site, the user gets created and then an email gets sent to
    22 the administrators of the site. An administrator then is expected to either 
    23 approve or deny the registration request. An email is then sent to the user 
     22the administrators of the site. An administrator then is expected to either
     23approve or deny the registration request. An email is then sent to the user
    2424indicating whether they were approved or denied. If the user has been approved,
    25 the email will include the login credentials. Until a user is approved, the 
     25the email will include the login credentials. Until a user is approved, the
    2626user will not be able to login to the site.
    2727
     
    51516. User logs in to site using login credentials.
    5252
    53 [Fork New User Approve on Github](https://github.com/picklewagon/new-user-approve)
    54 
    55 [newuserapprove.com](http://newuserapprove.com/)
     53**[Follow New User Approve on Github](https://github.com/picklewagon/new-user-approve)**
     54
     55Further support at [newuserapprove.com](http://newuserapprove.com/).
     56
     57**Customize**
     58
     59New User Approve allows for customizations by using custom actions and filters. You can
     60find out more about these by browsing the source code.
     61
     62A commercial plugin that adds a config panel for customization is also available at
     63[https://newuserapprove.com/products/options-addon/](https://newuserapprove.com/products/options-addon/).
    5664
    5765== Installation ==
     
    7381This is not a function of the plugin but of WordPress. WordPress provides the
    7482*wp_mail_from* and *wp_mail_from_name* filters to allow you to customize this.
    75 There are also a number of plugins that provide a setting to change this to 
     83There are also a number of plugins that provide a setting to change this to
    7684your liking.
    7785
    7886* [wp mail from](http://wordpress.org/extend/plugins/wp-mailfrom/)
    7987* [Mail From](http://wordpress.org/extend/plugins/mail-from/)
    80 
    81 = Why is the password reset when approving a user? =
    82 
    83 The password is generated again because, by default, the user will not be aware
    84 of their password. By generating a new password, the email that notifies the
    85 user can also give them the new password just like the email does when receiving
    86 your password on a regular WordPress install. At approval time, it is impossible
    87 to retrieve the user's password.
    88 
    89 There is a filter available (new_user_approve_bypass_password_reset) to turn off
    90 this feature.
    9188
    9289= What happens to the user's status after the plugin is deactivated? =
     
    105102
    106103== Changelog ==
     104
     105= 1.7.4 =
     106* Fixed: Corrected erroneous SQL query when filtering users
     107* Fixed: User filters
     108  * Courtesy of [julmuell](https://github.com/julmuell)
     109  * https://github.com/picklewagon/new-user-approve/pull/44
     110* Fixed: Show a user status in the filters only if at least one user has that status
    107111
    108112= 1.7.3 =
Note: See TracChangeset for help on using the changeset viewer.