WordPress.org

Plugin Directory

Changeset 607324


Ignore:
Timestamp:
10/03/12 06:20:37 (19 months ago)
Author:
picklewagon
Message:

merge in changes to trunk from 1.4 branch

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

Legend:

Unmodified
Added
Removed
  • new-user-approve/trunk/localization/new-user-approve-fr_FR.po

    r215316 r607324  
    44"Report-Msgid-Bugs-To: http://wordpress.org/tag/new-user-approve\n" 
    55"POT-Creation-Date: 2009-10-29 08:32+0000\n" 
    6 "PO-Revision-Date: 2010-03-09 01:00-0800\n" 
     6"PO-Revision-Date: 2012-06-18 22:39+0100\n" 
    77"Last-Translator: Josh Harrison <josh@picklewagon.com>\n" 
    88"Language-Team: Philippe Scoffoni <philippe@scoffoni.net>\n" 
     
    1818#: new-user-approve.php:140 
    1919msgid "Settings" 
    20 msgstr "Paramètres" 
     20msgstr "Param&#232;tres" 
    2121 
    2222#: new-user-approve.php:183 
     
    2626#: new-user-approve.php:219 
    2727msgid "User successfully updated." 
    28 msgstr "Utilisateur mis à jour avec succès" 
     28msgstr "Utilisateur mis &#224; jour avec succ&#232;s" 
    2929 
    3030#: new-user-approve.php:223 
     
    4242#: new-user-approve.php:229 
    4343msgid "Approved Users" 
    44 msgstr "Utilisateurs approuvés" 
     44msgstr "Utilisateurs approuv&#233;s" 
    4545 
    4646#: new-user-approve.php:230 
    4747msgid "Denied Users" 
    48 msgstr "Utilisateurs refusés" 
     48msgstr "Utilisateurs refus&#233;s" 
    4949 
    5050#: new-user-approve.php:255 
     
    8383#: new-user-approve.php:313 
    8484msgid "approved" 
    85 msgstr "approuvé" 
     85msgstr "approuv&#233;" 
    8686 
    8787#: new-user-approve.php:315 
    8888msgid "denied" 
    89 msgstr "refusé" 
     89msgstr "refus&#233;" 
    9090 
    9191#: new-user-approve.php:317 
     
    9696#, php-format 
    9797msgid "There are no users with a status of %s" 
    98 msgstr "il n'y a aucun utilisateur avec le status %s" 
     98msgstr "Il n'y a aucun utilisateur avec le status %s" 
    9999 
    100100#: new-user-approve.php:332 
    101101msgid "User name already exists" 
    102 msgstr "Nom d'utilisateur déjà existant" 
     102msgstr "Nom d'utilisateur d&#233;j&#224; existant" 
    103103 
    104104#: new-user-approve.php:335 
    105105#, php-format 
    106106msgid "%1$s (%2$s) has requested a username at %3$s" 
    107 msgstr "%1$s (%2$s) a demandé l'approbation d'un compte sur %3$s" 
     107msgstr "%1$s (%2$s) a demand&#233; l'approbation d'un compte sur %3$s" 
    108108 
    109109#: new-user-approve.php:337 
     
    120120#, php-format 
    121121msgid "You have been approved to access %s" 
    122 msgstr "Votre inscription a été acceptée pour accéder au site %s" 
     122msgstr "Votre inscription a &#233;t&#233; accept&#233;e pour acc&#233;der au site %s" 
    123123 
    124124#: new-user-approve.php:373 
     
    135135#, php-format 
    136136msgid "[%s] Registration Approved" 
    137 msgstr "[%s] Inscription approuvée" 
     137msgstr "[%s] Inscription approuv&#233;e" 
    138138 
    139139#: new-user-approve.php:397 
    140140#, php-format 
    141141msgid "You have been denied access to %s" 
    142 msgstr "Votre inscription a été refusée pour accéder au site %s" 
     142msgstr "Votre inscription a &#233;t&#233; refus&#233;e pour acc&#233;der au site %s" 
    143143 
    144144#: new-user-approve.php:400 
    145145#, php-format 
    146146msgid "[%s] Registration Denied" 
    147 msgstr "[%s] Inscription refusée" 
     147msgstr "[%s] Inscription refus&#233;e" 
    148148 
    149149#: new-user-approve.php:413 
    150150msgid "An email has been sent to the site administrator. The administrator will review the information that has been submitted and either approve or deny your request." 
    151 msgstr "Un email a été envoyé à l'administrateur du site. Il va vérifier les informations que vous avez transmises et approuver ou refuser votre demande d'inscription. " 
     151msgstr "Un email a &#233;t&#233; envoy&#233; &#224; l'administrateur du site. Il va v&#233;rifier les informations que vous avez transmises et approuver ou refuser votre demande d'inscription. " 
    152152 
    153153#: new-user-approve.php:414 
     
    161161#: new-user-approve.php:418 
    162162msgid "Registration successful." 
    163 msgstr "Inscription réussie" 
     163msgstr "Inscription r&#233;ussie" 
    164164 
    165165#: new-user-approve.php:466 
    166166#, php-format 
    167167msgid "Welcome to %s. This site is accessible to approved users only. To be approved, you must first register." 
    168 msgstr "Bienvenue à %s. Ce site est accessible aux utilisateurs approuvés. Pour être approuvé, vous devez d'abord vous inscrire." 
     168msgstr "Bienvenue sur le site %s. Ce site est accessible aux utilisateurs approuv&#233;s. Pour &#234;tre approuv&#233;, vous devez d'abord vous inscrire." 
    169169 
    170170#: new-user-approve.php:471 
    171171msgid "After you register, your request will be sent to the site administrator for approval. You will then receive an email with further instructions." 
    172 msgstr "Après l'inscription, votre demande sera envoyée à l'administrateur pour approbation. Vous recevrez alors un email avec plus d'informations." 
     172msgstr "Apr&#232;s l'inscription, votre demande sera envoy&#233;e &#224; l'administrateur pour approbation. Vous recevrez alors un email avec plus d'informations." 
    173173 
    174174#. Plugin Name of an extension 
    175175msgid "New User Approve" 
    176 msgstr "Nouvel utilisateur approuvé" 
     176msgstr "Nouvel utilisateur approuv&#233;" 
    177177 
    178178#. Plugin URI of an extension 
  • new-user-approve/trunk/new-user-approve.php

    r552419 r607324  
    55 Description: This plugin allows administrators to approve users once they register. Only approved users will be allowed to access the blog. For support, please go to the <a href="http://wordpress.org/support/plugin/new-user-approve">support forums</a> on wordpress.org. 
    66 Author: Josh Harrison 
    7  Version: 1.3.4 
     7 Version: 1.4 
    88 Author URI: http://www.picklewagon.com/ 
    99 */ 
     
    2525 */ 
    2626 
    27 if (!class_exists('pw_new_user_approve')) { 
     27if ( ! class_exists( 'pw_new_user_approve' ) ) { 
    2828class pw_new_user_approve { 
    2929    /** 
     
    4848        // Load up the localization file if we're using WordPress in a different language 
    4949        // Just drop it in this plugin's "localization" folder and name it "new-user-approve-[value in wp-config].mo" 
    50         load_plugin_textdomain($this->plugin_id, false, dirname(plugin_basename(__FILE__)) . '/localization'); 
    51  
    52         register_activation_hook(__FILE__, array( $this, 'activation_check')); 
     50        load_plugin_textdomain( $this->plugin_id, false, dirname( plugin_basename( __FILE__ ) ) . '/localization' ); 
     51 
     52        register_activation_hook( __FILE__, array( $this, 'activation_check' ) ); 
    5353 
    5454        // Actions 
    55         add_action('admin_menu',          array( $this, 'admin_menu_link')); 
    56         add_action('admin_footer',        array( $this, 'admin_scripts_footer')); 
    57         add_action('init',                array( $this, 'init')); 
    58         add_action('init',                array( $this, 'process_input')); 
    59         add_action('register_post',       array( $this, 'send_approval_email'), 10, 3); 
    60         add_action('lostpassword_post',   array( $this, 'lost_password')); 
    61         add_action( 'user_register',      array( $this, 'add_user_status' ) ); 
     55        add_action( 'admin_menu', array( $this, 'admin_menu_link' ) ); 
     56        add_action( 'admin_footer', array( $this, 'admin_scripts_footer' ) ); 
     57        add_action( 'init', array( $this, 'init' ) ); 
     58        add_action( 'init', array( $this, 'process_input' ) ); 
     59        add_action( 'register_post', array( $this, 'send_approval_email' ), 10, 3 ); 
     60        add_action( 'lostpassword_post', array( $this, 'lost_password' ) ); 
     61        add_action( 'user_register', array( $this, 'add_user_status' ) ); 
     62        add_action( 'new_user_approve_approve_user', array( $this, 'approve_user' ) ); 
     63        add_action( 'new_user_approve_deny_user', array( $this, 'deny_user' ) ); 
    6264        //add_action('rightnow_end', array( $this, 'dashboard_stats')); // still too slow 
    6365 
    6466        // Filters 
    65         add_filter('registration_errors', array( $this, 'show_user_message'), 10, 1); 
    66         add_filter('login_message', array( $this, 'welcome_user')); 
    67         add_filter( 'wp_authenticate_user', array( $this, 'authenticate_user' ), 10, 2); 
     67        add_filter( 'registration_errors', array( $this, 'show_user_pending_message' ), 10, 1 ); 
     68        add_filter( 'login_message', array( $this, 'welcome_user' ) ); 
     69        add_filter( 'wp_authenticate_user', array( $this, 'authenticate_user' ), 10, 2 ); 
    6870    } 
    6971 
     
    7274 
    7375        $min_wp_version = '3.1'; 
    74         $exit_msg = sprintf( __('New User Approve requires WordPress %s or newer.', $this->plugin_id), $min_wp_version ); 
    75         if (version_compare($wp_version, $min_wp_version, '<=')) { 
    76             exit($exit_msg); 
     76        $exit_msg = sprintf( __( 'New User Approve requires WordPress %s or newer.', $this->plugin_id ), $min_wp_version ); 
     77        if ( version_compare( $wp_version, $min_wp_version, '<=' ) ) { 
     78            exit( $exit_msg ); 
    7779        } 
    7880    } 
     
    8183        global $wp_db_version; 
    8284 
    83         if ( is_admin() && isset( $_GET['page'] ) && $_GET['page'] == $this->_admin_page) { 
    84             $page_id = ($wp_db_version >= 10851) ? '#pw_approve_tabs' : '#pw_approve_tabs > ul'; 
     85        if ( is_admin() && isset( $_GET['page'] ) && $_GET['page'] == $this->_admin_page ) { 
     86            $page_id = ( $wp_db_version >= 10851 ) ? '#pw_approve_tabs' : '#pw_approve_tabs > ul'; 
    8587?> 
    8688<script type="text/javascript"> 
     
    9799    public function dashboard_stats() { 
    98100        // Query the users table 
    99         $wp_user_search = new WP_User_Search($_GET['usersearch'], $_GET['userspage']); 
     101        $wp_user_search = new WP_User_Search( $_GET['usersearch'], $_GET['userspage'] ); 
    100102        $user_status = array(); 
    101103 
    102104        // Make the user objects 
    103         foreach ($wp_user_search->get_results() as $userid) { 
    104             $user = new WP_User($userid); 
    105             $status = get_usermeta($userid, 'pw_user_status'); 
    106             if ($status == '') { // user was created in admin 
    107                 update_user_meta($userid, 'pw_user_status', 'approved'); 
    108                 $status = get_usermeta($userid, 'pw_user_status'); 
    109             } 
    110             if ($user_status[$status] == null) { 
     105        foreach ( $wp_user_search->get_results() as $userid ) { 
     106            $user = new WP_User( $userid ); 
     107            $status = get_usermeta( $userid, 'pw_user_status' ); 
     108            if ( $status == '' ) { // user was created in admin 
     109                update_user_meta( $userid, 'pw_user_status', 'approved' ); 
     110                $status = get_usermeta( $userid, 'pw_user_status' ); 
     111            } 
     112            if ( $user_status[$status] == null ) { 
    111113                $user_status[$status] = 0; 
    112114            } 
     
    115117?> 
    116118            <div> 
    117                 <p><span style="font-weight:bold;"><a href="users.php?page=<?php print $this->_admin_page ?>"><?php _e('Users', $this->plugin_id) ?></a></span>: 
    118                 <?php foreach($user_status as $status =>$count) print "$count $status&nbsp;&nbsp;"; ?> 
     119                <p><span style="font-weight:bold;"><a href="users.php?page=<?php print $this->_admin_page ?>"><?php _e( 'Users', $this->plugin_id ); ?></a></span>: 
     120                <?php foreach ( $user_status as $status => $count ) print "$count $status&nbsp;&nbsp;"; ?> 
    119121                </p> 
    120122            </div> 
     
    126128     */ 
    127129    public function approve_admin() { 
    128         if (isset($_GET['user']) && isset($_GET['status'])) { 
    129             echo '<div id="message" class="updated fade"><p>'.__('User successfully updated.', $this->plugin_id).'</p></div>'; 
     130        if ( isset( $_GET['user'] ) && isset( $_GET['status'] ) ) { 
     131            echo '<div id="message" class="updated fade"><p>'.__( 'User successfully updated.', $this->plugin_id ).'</p></div>'; 
    130132        } 
    131133?> 
    132134        <div class="wrap"> 
    133             <h2><?php _e('User Registration Approval', $this->plugin_id) ?></h2> 
    134  
    135             <h3><?php _e('User Management', $this->plugin_id) ?></h3> 
     135            <h2><?php _e( 'User Registration Approval', $this->plugin_id ); ?></h2> 
     136 
     137            <h3><?php _e( 'User Management', $this->plugin_id ); ?></h3> 
    136138            <div id="pw_approve_tabs"> 
    137139                <ul> 
    138                     <li><a href="#pw_pending_users"><span><?php _e('Users Pending Approval', $this->plugin_id) ?></span></a></li> 
    139                     <li><a href="#pw_approved_users"><span><?php _e('Approved Users', $this->plugin_id) ?></span></a></li> 
    140                     <li><a href="#pw_denied_users"><span><?php _e('Denied Users', $this->plugin_id) ?></span></a></li> 
     140                    <li><a href="#pw_pending_users"><span><?php _e( 'Users Pending Approval', $this->plugin_id ); ?></span></a></li> 
     141                    <li><a href="#pw_approved_users"><span><?php _e( 'Approved Users', $this->plugin_id ); ?></span></a></li> 
     142                    <li><a href="#pw_denied_users"><span><?php _e( 'Denied Users', $this->plugin_id ); ?></span></a></li> 
    141143                </ul> 
    142144                <div id="pw_pending_users"> 
    143                     <?php $this->approve_table( 'pending', true, true ); ?> 
     145                    <?php $this->user_table( 'pending' ); ?> 
    144146                </div> 
    145147                <div id="pw_approved_users"> 
    146                     <?php $this->approve_table( 'approved', false, true ); ?> 
     148                    <?php $this->user_table( 'approved' ); ?> 
    147149                </div> 
    148150                <div id="pw_denied_users"> 
    149                     <?php $this->approve_table( 'denied', true, false ); ?> 
     151                    <?php $this->user_table( 'denied' ); ?> 
    150152                </div> 
    151153            </div> 
     
    155157 
    156158    /** 
    157      * @desc the table that shows the registered users grouped by status 
    158      */ 
    159     public function approve_table($status, $approve, $deny) { 
     159     * Output the table that shows the registered users grouped by status 
     160     *  
     161     * @param string $status the filter to use for which the users will be queried. Possible values are pending, approved, or denied. 
     162     */ 
     163    public function user_table( $status ) { 
    160164        global $current_user; 
    161  
     165         
     166        $approve = ( 'denied' == $status || 'pending' == $status ); 
     167        $deny = ( 'approved' == $status || 'pending' == $status ); 
     168         
    162169        if ( $status != 'approved' ) { 
    163170            // Query the users table 
     
    178185            } 
    179186 
    180             // get all approved users and any usr without a status 
     187            // get all approved users and any user without a status 
    181188            $query = array( 'include' => $approved_users ); 
    182189            $wp_user_search = new WP_User_Query( $query ); 
     
    184191 
    185192        if ( isset( $wp_user_search ) && $wp_user_search->total_users > 0 ) { 
     193            $users = $wp_user_search->get_results(); 
     194            $users = apply_filters( 'new_user_approve_user_status', $users, $status ); 
    186195        ?> 
    187196<table class="widefat"> 
    188197    <thead> 
    189198        <tr class="thead"> 
    190             <th><?php _e('Username', $this->plugin_id) ?></th> 
    191             <th><?php _e('Name', $this->plugin_id) ?></th> 
    192             <th><?php _e('E-mail', $this->plugin_id) ?></th> 
    193         <?php if ($approve && $deny) { ?> 
    194             <th colspan="2" style="text-align: center"><?php _e('Actions', $this->plugin_id) ?></th> 
     199            <th><?php _e( 'Username', $this->plugin_id ); ?></th> 
     200            <th><?php _e( 'Name', $this->plugin_id ); ?></th> 
     201            <th><?php _e( 'E-mail', $this->plugin_id ); ?></th> 
     202        <?php if ( 'pending' == $status ) { ?> 
     203            <th colspan="2" style="text-align: center"><?php _e( 'Actions', $this->plugin_id ); ?></th> 
    195204        <?php } else { ?> 
    196             <th style="text-align: center"><?php _e('Actions', $this->plugin_id) ?></th> 
     205            <th style="text-align: center"><?php _e( 'Actions', $this->plugin_id ); ?></th> 
    197206        <?php } ?> 
    198207        </tr> 
     
    202211        // show each of the users 
    203212        $row = 1; 
    204         foreach ($wp_user_search->get_results() as $user) { 
    205             $class = ($row % 2) ? '' : ' class="alternate"'; 
     213        foreach ( $users as $user ) { 
     214            $class = ( $row % 2 ) ? '' : ' class="alternate"'; 
    206215            $avatar = get_avatar( $user->user_email, 32 ); 
    207             if ($approve) { 
    208                 $approve_link = get_option('siteurl').'/wp-admin/users.php?page='.$this->_admin_page.'&user='.$user->ID.'&status=approve'; 
    209                 $approve_link = wp_nonce_url($approve_link, 'pw_new_user_approve_action_' . get_class($this)); 
    210             } 
    211             if ($deny) { 
    212                 $deny_link = get_option('siteurl').'/wp-admin/users.php?page='.$this->_admin_page.'&user='.$user->ID.'&status=deny'; 
    213                 $deny_link = wp_nonce_url($deny_link, 'pw_new_user_approve_action_' . get_class($this)); 
     216            if ( $approve ) { 
     217                $approve_link = get_option( 'siteurl' ) . '/wp-admin/users.php?page=' . $this->_admin_page . '&user=' . $user->ID . '&status=approve'; 
     218                $approve_link = wp_nonce_url( $approve_link, 'pw_new_user_approve_action_' . get_class( $this ) ); 
     219            } 
     220            if ( $deny ) { 
     221                $deny_link = get_option( 'siteurl' ) . '/wp-admin/users.php?page=' . $this->_admin_page . '&user=' . $user->ID . '&status=deny'; 
     222                $deny_link = wp_nonce_url( $deny_link, 'pw_new_user_approve_action_' . get_class( $this ) ); 
    214223            } 
    215224            if ( current_user_can( 'edit_user', $user->ID ) ) { 
     
    225234 
    226235            ?><tr <?php echo $class; ?>> 
    227                 <td><?php echo $avatar." ".$edit; ?></td> 
    228                 <td><?php echo get_user_meta( $user->ID, 'first_name', true )." ".get_user_meta( $user->ID, 'last_name', true ); ?></td> 
     236                <td><?php echo $avatar . ' ' . $edit; ?></td> 
     237                <td><?php echo get_user_meta( $user->ID, 'first_name', true ) . ' ' . get_user_meta( $user->ID, 'last_name', true ); ?></td> 
    229238                <td><a href="mailto:<?php echo $user->user_email; ?>" title="<?php _e('email:', $this->plugin_id) ?> <?php echo $user->user_email; ?>"><?php echo $user->user_email; ?></a></td> 
    230                 <?php if ($approve) { ?> 
    231                 <td align="center"><a href="<?php echo $approve_link; ?>" title="<?php _e('Approve', $this->plugin_id) ?> <?php echo $user->user_login; ?>"><?php _e('Approve', $this->plugin_id) ?></a></td> 
     239                <?php if ( $approve ) { ?> 
     240                <td align="center"><a href="<?php echo $approve_link; ?>" title="<?php _e( 'Approve', $this->plugin_id ); ?> <?php echo $user->user_login; ?>"><?php _e( 'Approve', $this->plugin_id ); ?></a></td> 
    232241                <?php } ?> 
    233                 <?php if ($deny) { ?> 
    234                 <td align="center"><a href="<?php echo $deny_link; ?>" title="<?php _e('Deny', $this->plugin_id) ?> <?php echo $user->user_login; ?>"><?php _e('Deny', $this->plugin_id) ?></a></td> 
     242                <?php if ( $deny ) { ?> 
     243                <td align="center"><a href="<?php echo $deny_link; ?>" title="<?php _e( 'Deny', $this->plugin_id ); ?> <?php echo $user->user_login; ?>"><?php _e( 'Deny', $this->plugin_id ); ?></a></td> 
    235244                <?php } ?> 
    236245            </tr><?php 
     
    243252        } else { 
    244253            $status_i18n = $status; 
    245             if ($status == 'approved') { 
    246                 $status_i18n = __('approved', $this->plugin_id); 
    247             } else if ($status == 'denied') { 
    248                 $status_i18n = __('denied', $this->plugin_id); 
    249             } else if ($status == 'pending') { 
    250                 $status_i18n = __('pending', $this->plugin_id); 
    251             } 
    252  
    253             echo '<p>'.sprintf(__('There are no users with a status of %s', $this->plugin_id), $status_i18n).'</p>'; 
     254            if ( $status == 'approved' ) { 
     255                $status_i18n = __( 'approved', $this->plugin_id ); 
     256            } else if ( $status == 'denied' ) { 
     257                $status_i18n = __( 'denied', $this->plugin_id ); 
     258            } else if ( $status == 'pending' ) { 
     259                $status_i18n = __( 'pending', $this->plugin_id ); 
     260            } 
     261 
     262            echo '<p>'.sprintf( __( 'There are no users with a status of %s', $this->plugin_id ), $status_i18n ) . '</p>'; 
    254263        } 
    255264    } 
     
    258267     * @desc send an email to the admin to request approval 
    259268     */ 
    260     public function send_approval_email($user_login, $user_email, $errors) { 
    261         if (!$errors->get_error_code()) { 
     269    public function send_approval_email( $user_login, $user_email, $errors ) { 
     270        if ( ! $errors->get_error_code() ) { 
    262271            /* check if already exists */ 
    263272            $user_data = get_user_by( 'login', $user_login ); 
    264             if (!empty($user_data)){ 
    265                 $errors->add('registration_required' , __('User name already exists', $this->plugin_id), 'message'); 
     273            if ( ! empty( $user_data ) ){ 
     274                $errors->add( 'registration_required' , __( 'User name already exists', $this->plugin_id ), 'message' ); 
    266275            } else { 
    267276                /* send email to admin for approval */ 
    268                 $message  = sprintf(__('%1$s (%2$s) has requested a username at %3$s', $this->plugin_id), $user_login, $user_email, get_option('blogname')) . "\r\n\r\n"; 
    269                 $message .= get_option('siteurl') . "\r\n\r\n"; 
    270                 $message .= sprintf(__('To approve or deny this user access to %s go to', $this->plugin_id), get_option('blogname')) . "\r\n\r\n"; 
    271                 $message .= get_option('siteurl') . "/wp-admin/users.php?page=".$this->_admin_page."\r\n"; 
     277                $message  = sprintf( __( '%1$s (%2$s) has requested a username at %3$s', $this->plugin_id ), $user_login, $user_email, get_option( 'blogname' ) ) . "\r\n\r\n"; 
     278                $message .= get_option( 'siteurl' ) . "\r\n\r\n"; 
     279                $message .= sprintf( __( 'To approve or deny this user access to %s go to', $this->plugin_id ), get_option( 'blogname' ) ) . "\r\n\r\n"; 
     280                $message .= get_option( 'siteurl' ) . '/wp-admin/users.php?page=' . $this->_admin_page . "\r\n"; 
     281                 
     282                $message = apply_filters( 'new_user_approve_request_approval_message', $message, $user_login, $user_email ); 
     283                 
     284                $subject = sprintf( __( '[%s] User Approval', $this->plugin_id ), get_option( 'blogname' ) ); 
     285                $subject = apply_filters( 'new_user_approve_request_approval_subject', $subject ); 
    272286 
    273287                // send the mail 
    274                 wp_mail(get_option('admin_email'), sprintf(__('[%s] User Approval', $this->plugin_id), get_option('blogname')), $message); 
     288                wp_mail( get_option( 'admin_email' ), $subject, $message ); 
    275289 
    276290                // create the user 
    277291                $user_pass = wp_generate_password(); 
    278                 $user_id = wp_create_user($user_login, $user_pass, $user_email); 
     292                $user_id = wp_create_user( $user_login, $user_pass, $user_email ); 
    279293            } 
    280294        } 
     
    290304        $user = new WP_User( $user_id ); 
    291305 
    292         // reset password to know what to send the user 
    293         $new_pass = wp_generate_password(); 
    294         $data = array( 
    295             'user_pass' => md5($new_pass), 
    296             'user_activation_key' => '', 
    297         ); 
    298         $where = array( 
    299             'ID' => $user->ID, 
    300         ); 
    301         $wpdb->update($wpdb->users, $data, $where, array('%s', '%s'), array('%d')); 
    302  
    303         wp_cache_delete($user->ID, 'users'); 
    304         wp_cache_delete($user->user_login, 'userlogins'); 
     306        $bypass_password_reset = apply_filters( 'new_user_approve_bypass_password_reset', false ); 
     307         
     308        if ( ! $bypass_password_reset ) { 
     309            // reset password to know what to send the user 
     310            $new_pass = wp_generate_password(); 
     311            $data = array( 
     312                'user_pass' => md5($new_pass), 
     313                'user_activation_key' => '', 
     314            ); 
     315            $where = array( 
     316                'ID' => $user->ID, 
     317            ); 
     318            $wpdb->update($wpdb->users, $data, $where, array( '%s', '%s' ), array( '%d' ) ); 
     319        } 
     320 
     321        wp_cache_delete( $user->ID, 'users' ); 
     322        wp_cache_delete( $user->user_login, 'userlogins' ); 
    305323 
    306324        // send email to user telling of approval 
    307         $user_login = stripslashes($user->user_login); 
    308         $user_email = stripslashes($user->user_email); 
     325        $user_login = stripslashes( $user->user_login ); 
     326        $user_email = stripslashes( $user->user_email ); 
    309327 
    310328        // format the message 
    311         $message  = sprintf(__('You have been approved to access %s', $this->plugin_id), get_option('blogname')) . "\r\n"; 
    312         $message .= sprintf(__('Username: %s', $this->plugin_id), $user_login) . "\r\n"; 
    313         $message .= sprintf(__('Password: %s', $this->plugin_id), $new_pass) . "\r\n"; 
    314         $message .= get_option('siteurl') . "/wp-login.php\r\n"; 
    315  
     329        $message  = sprintf( __( 'You have been approved to access %s', $this->plugin_id ), get_option( 'blogname' ) ) . "\r\n"; 
     330        $message .= sprintf( __( 'Username: %s', $this->plugin_id ), $user_login ) . "\r\n"; 
     331        if ( ! $bypass_password_reset ) { 
     332            $message .= sprintf( __( 'Password: %s', $this->plugin_id ), $new_pass ) . "\r\n"; 
     333        } 
     334        $message .= get_option( 'siteurl' ) . "/wp-login.php\r\n"; 
     335 
     336        $message = apply_filters( 'new_user_approve_approve_user_message', $message, $user ); 
     337         
     338        $subject = sprintf( __( '[%s] Registration Approved', $this->plugin_id ), get_option( 'blogname' ) ); 
     339        $subject = apply_filters( 'new_user_approve_approve_user_subject', $subject ); 
     340         
    316341        // send the mail 
    317         @wp_mail($user_email, sprintf(__('[%s] Registration Approved', $this->plugin_id), get_option('blogname')), $message); 
     342        @wp_mail( $user_email, $subject, $message ); 
    318343 
    319344        // change usermeta tag in database to approved 
    320         update_user_meta($user->ID, 'pw_user_status', 'approved'); 
     345        update_user_meta( $user->ID, 'pw_user_status', 'approved' ); 
     346         
     347        do_action( 'new_user_approve_user_approved', $user ); 
    321348    } 
    322349 
     
    329356 
    330357        // send email to user telling of denial 
    331         $user_email = stripslashes($user->user_email); 
     358        $user_email = stripslashes( $user->user_email ); 
    332359 
    333360        // format the message 
    334         $message = sprintf(__('You have been denied access to %s', $this->plugin_id), get_option('blogname')); 
     361        $message = sprintf( __( 'You have been denied access to %s', $this->plugin_id ), get_option( 'blogname' ) ); 
     362        $message = apply_filters( 'new_user_approve_deny_user_message', $message, $user ); 
     363         
     364        $subject = sprintf( __( '[%s] Registration Denied', $this->plugin_id ), get_option( 'blogname' ) ); 
     365        $subject = apply_filters( 'new_user_approve_deny_user_subject', $subject ); 
    335366 
    336367        // send the mail 
    337         @wp_mail($user_email, sprintf(__('[%s] Registration Denied', $this->plugin_id), get_option('blogname')), $message); 
     368        @wp_mail( $user_email, $subject, $message ); 
    338369 
    339370        // change usermeta tag in database to denied 
    340         update_user_meta($user->ID, 'pw_user_status', 'denied'); 
    341     } 
    342  
    343     /** 
    344      * @desc display a message to the user if they have not been approved 
    345      */ 
    346     public function show_user_message($errors) { 
     371        update_user_meta( $user->ID, 'pw_user_status', 'denied' ); 
     372         
     373        do_action( 'new_user_approve_user_denied', $user ); 
     374    } 
     375 
     376    /** 
     377     * Display a message to the user after they have registered 
     378     */ 
     379    public function show_user_pending_message($errors) { 
     380        if ( ! empty( $_POST['redirect_to'] ) ) { 
     381            // if a redirect_to is set, honor it 
     382            wp_safe_redirect( $_POST['redirect_to'] ); 
     383            exit(); 
     384        } 
     385         
     386        // if there is an error already, let it do it's thing 
    347387        if ( $errors->get_error_code() ) 
    348388            return $errors; 
    349  
    350         $message  = sprintf(__('An email has been sent to the site administrator. The administrator will review the information that has been submitted and either approve or deny your request.', $this->plugin_id)); 
    351         $message .= sprintf(__('You will receive an email with instructions on what you will need to do next. Thanks for your patience.', $this->plugin_id)); 
    352  
    353         $errors->add('registration_required', $message, 'message'); 
    354  
    355         if (function_exists('login_header')) { 
    356             login_header(__('Pending Approval', $this->plugin_id), '<p class="message register">' . __("Registration successful.", $this->plugin_id) . '</p>', $errors); 
    357         } 
    358  
    359         echo "<body></html>"; 
    360         exit(); 
     389         
     390        $message  = sprintf( __( 'An email has been sent to the site administrator. The administrator will review the information that has been submitted and either approve or deny your request.', $this->plugin_id ) ); 
     391        $message .= sprintf( __( 'You will receive an email with instructions on what you will need to do next. Thanks for your patience.', $this->plugin_id ) ); 
     392        $message = apply_filters( 'new_user_approve_pending_message', $message ); 
     393 
     394        $errors->add( 'registration_required', $message, 'message' ); 
     395 
     396        $success_message = __( 'Registration successful.', $this->plugin_id ); 
     397        $success_message = apply_filters( 'new_user_approve_registration_message', $success_message ); 
     398         
     399        if ( function_exists( 'login_header' ) ) { 
     400            login_header( __( 'Pending Approval', $this->plugin_id ), '<p class="message register">' . $success_message . '</p>', $errors ); 
     401            login_footer(); 
     402             
     403            // an exit is necessay here so the normal process for user registration doesn't happen 
     404            exit(); 
     405        } 
    361406    } 
    362407 
     
    365410     */ 
    366411    public function process_input() { 
    367         if ((isset($_GET['page']) && $_GET['page'] == $this->_admin_page) && isset($_GET['status'])) { 
    368             $valid_request = check_admin_referer('pw_new_user_approve_action_' . get_class($this)); 
    369  
    370             if ($valid_request) { 
    371                 if ($_GET['status'] == 'approve') { 
    372                     $this->approve_user(); 
     412        if ( ( isset( $_GET['page'] ) && $_GET['page'] == $this->_admin_page ) && isset( $_GET['status'] ) ) { 
     413            $valid_request = check_admin_referer( 'pw_new_user_approve_action_' . get_class( $this ) ); 
     414 
     415            if ( $valid_request ) { 
     416                if ( $_GET['status'] == 'approve' ) { 
     417                    do_action( 'new_user_approve_approve_user' ); 
    373418                } 
    374419 
    375                 if ($_GET['status'] == 'deny') { 
    376                     $this->deny_user(); 
     420                if ( $_GET['status'] == 'deny' ) { 
     421                    do_action( 'new_user_approve_deny_user' ); 
    377422                } 
    378423            } 
     
    384429     */ 
    385430    public function lost_password() { 
    386         $is_email = strpos($_POST['user_login'], '@'); 
    387         if ($is_email === false) { 
     431        $is_email = strpos( $_POST['user_login'], '@' ); 
     432        if ( $is_email === false ) { 
    388433            $username = sanitize_user( $_POST['user_login'] ); 
    389434            $user_data = get_user_by( 'login', trim( $username ) ); 
     
    393438        } 
    394439 
    395         if ($user_data->pw_user_status != 'approved') { 
    396             wp_redirect('wp-login.php'); 
     440        if ( $user_data->pw_user_status != 'approved' ) { 
     441            wp_redirect( 'wp-login.php' ); 
    397442            exit(); 
    398443        } 
     
    402447 
    403448    public function welcome_user($message) { 
    404         if (!isset($_GET['action'])) { 
    405             $inside = sprintf(__('Welcome to %s. This site is accessible to approved users only. To be approved, you must first register.', $this->plugin_id), get_option('blogname')); 
    406             $message .= '<p class="message">' . $inside . '</p>'; 
    407         } 
    408  
    409         if ( isset( $_GET['action'] ) && $_GET['action'] == 'register' && !$_POST ) { 
    410             $inside = sprintf(__('After you register, your request will be sent to the site administrator for approval. You will then receive an email with further instructions.', $this->plugin_id)); 
    411             $message .= '<p class="message">' . $inside . '</p>'; 
     449        if ( ! isset( $_GET['action'] ) ) { 
     450            $welcome = sprintf( __( 'Welcome to %s. This site is accessible to approved users only. To be approved, you must first register.', $this->plugin_id ), get_option( 'blogname' ) ); 
     451            $welcome = apply_filters( 'new_user_approve_welcome_message', $welcome ); 
     452             
     453            $message .= '<p class="message">' . $welcome . '</p>'; 
     454        } 
     455 
     456        if ( isset( $_GET['action'] ) && $_GET['action'] == 'register' && ! $_POST ) { 
     457            $instructions = sprintf( __( 'After you register, your request will be sent to the site administrator for approval. You will then receive an email with further instructions.', $this->plugin_id ) ); 
     458            $instructions = apply_filters( 'new_user_approve_register_instructions', $instructions ); 
     459             
     460            $message .= '<p class="message">' . $instructions . '</p>'; 
    412461        } 
    413462 
     
    416465 
    417466    public function init() { 
    418         if ( is_admin() && isset($_GET['page']) && $_GET['page'] == $this->_admin_page ) { 
     467        if ( is_admin() && isset( $_GET['page'] ) && $_GET['page'] == $this->_admin_page ) { 
    419468            wp_enqueue_script('jquery-ui-tabs'); 
    420469            wp_enqueue_style('pw-admin-ui-tabs', plugins_url( 'ui.tabs.css', __FILE__ ) ); 
     
    424473    function admin_menu_link() { 
    425474        $cap = apply_filters( 'new_user_approve_minimum_cap', 'edit_users' ); 
    426         $this->user_page_hook = add_users_page( __('Approve New Users', $this->plugin_id), __('Approve New Users', $this->plugin_id), $cap, $this->_admin_page, array( $this, 'approve_admin' ) ); 
     475        $this->user_page_hook = add_users_page( __( 'Approve New Users', $this->plugin_id ), __( 'Approve New Users', $this->plugin_id ), $cap, $this->_admin_page, array( $this, 'approve_admin' ) ); 
    427476    } 
    428477 
     
    438487        switch ( $status ) { 
    439488            case 'pending': 
    440                 $message = new WP_Error('pending_approval', __('<strong>ERROR</strong>: Your account is still pending approval.')); 
     489                $pending_message = __( '<strong>ERROR</strong>: Your account is still pending approval.' ); 
     490                $pending_message = apply_filters( 'new_user_approve_pending_error', $pending_message ); 
     491                 
     492                $message = new WP_Error( 'pending_approval', $pending_message ); 
    441493                break; 
    442494            case 'denied': 
    443                 $message = new WP_Error('denied_access', __('<strong>ERROR</strong>: Your account has been denied access to this site.')); 
     495                $denied_message = __( '<strong>ERROR</strong>: Your account has been denied access to this site.' ); 
     496                $denied_message = apply_filters( 'new_user_approve_denied_error', $denied_message ); 
     497                 
     498                $message = new WP_Error( 'denied_access', $denied_message ); 
    444499                break; 
    445500            case 'approved': 
     
    453508    public function add_user_status( $user_id ) { 
    454509        $status = 'pending'; 
    455         if ( isset($_REQUEST['action']) && 'createuser' == $_REQUEST['action'] ) { 
     510        if ( isset( $_REQUEST['action'] ) && 'createuser' == $_REQUEST['action'] ) { 
    456511            $status = 'approved'; 
    457512        } 
     
    463518 
    464519// instantiate the class 
    465 if (class_exists('pw_new_user_approve')) { 
     520if ( class_exists( 'pw_new_user_approve' ) ) { 
    466521    $pw_new_user_approve = new pw_new_user_approve(); 
    467522} 
  • new-user-approve/trunk/readme.txt

    r592216 r607324  
    44Tags: users, registration 
    55Requires at least: 3.2.1 
    6 Tested up to: 3.4.1 
     6Tested up to: 3.4.2 
    77Stable tag: 1.3.4 
    88 
     
    4747* [Mail From](http://wordpress.org/extend/plugins/mail-from/) 
    4848 
     49= Why is the password reset when approving a user? = 
     50 
     51The password is generated again because, by default, the user will not be aware 
     52of their password. By generating a new password, the email that notifies the 
     53user can also give them the new password just like the email does when recieving 
     54your password on a regular WordPress install. At approval time, it is impossible 
     55to retrieve the user's password. 
     56 
     57There is a filter available (new_user_approve_bypass_password_reset) to turn off 
     58this feature. 
     59 
    4960== Screenshots == 
    5061 
     
    5364== Changelog == 
    5465 
    55 = 1.3.5 = 
    56 * add Croatian translation 
     66= 1.4 = 
     67* add filters 
     68* honor the redirect if there is one set when registering 
     69* add actions for when a user is approved or denied 
     70* add a filter to bypass password reset 
     71* add more translations 
    5772 
    5873= 1.3.4 = 
     
    147162== Other Notes == 
    148163 
     164= Filters = 
     165* *new_user_approve_user_status* - modify the list of users shown in the tables 
     166* *new_user_approve_request_approval_message* - modify the request approval message 
     167* *new_user_approve_request_approval_subject* - modify the request approval subject 
     168* *new_user_approve_approve_user_message* - modify the user approval message 
     169* *new_user_approve_approve_user_subject* - modify the user approval subject 
     170* *new_user_approve_deny_user_message* - modify the user denial message 
     171* *new_user_approve_deny_user_subject* - modify the user denial subject 
     172* *new_user_approve_pending_message* - modify message user sees after registration 
     173* *new_user_approve_registration_message* - modify message after a successful registration 
     174* *new_user_approve_register_instructions* - modify message that appears on registration screen 
     175* *new_user_approve_pending_error* - error message shown to pending users when attempting to log in 
     176* *new_user_approve_denied_error* - error message shown to denied users when attempting to log in 
     177 
    149178= Translations = 
    150179The plugin has been prepared to be translated. If you want to help to translate the plugin to your language, please have a look at the localization/new-user-approve.pot file which contains all defintions and may be used with a gettext editor like Poedit (Windows). More information can be found on the [Codex](http://codex.wordpress.org/Translating_WordPress). 
    151180 
     181When sending me your translation files, please send me your wordpress.org username as well. 
     182 
    152183* Belarusian translation by [Fat Cow](http://www.fatcow.com/) 
     184* Catalan translation by [xoanet](http://profiles.wordpress.org/xoanet/) 
     185* Croation translation by Nik 
     186* Czech translation by [GazikT](http://profiles.wordpress.org/gazikt/) 
    153187* Danish translation by [GeorgWP](http://wordpress.org/support/profile/georgwp) 
     188* Dutch translation by [Ronald Moolenaar](http://profiles.wordpress.org/moolie/) 
     189* Finnish translation by Tonttu-ukko 
    154190* French translation by [Philippe Scoffoni](http://philippe.scoffoni.net/) 
     191* German translation by Christoph Ploedt 
    155192* Greek translation by [Leftys](http://alt3rnet.info/) 
     193* Italian translation by [Pierfrancesco Marsiaj](http://profiles.wordpress.org/pierinux/) 
    156194* Polish translation by [pik256](http://wordpress.org/support/profile/1271256) 
    157 * German translation by Christoph Ploedt 
     195* Romanian translation by [Web Hosting Geeks](http://webhostinggeeks.com/) 
     196* Russion translation by [Alexey](http://wordpress.org/support/profile/asel) 
    158197* Spanish translation by [Eduardo Aranda](http://sinetiks.com/) 
    159 * Dutch translation by [Ronald Moolenaar](http://profiles.wordpress.org/moolie/) 
    160 * Italian translation by [Pierfrancesco Marsiaj](http://profiles.wordpress.org/pierinux/) 
    161 * Czech translation by [GazikT](http://profiles.wordpress.org/gazikt/) 
    162 * Catalan translation by [xoanet](http://profiles.wordpress.org/xoanet/) 
    163 * Romanian translation by [Web Hosting Geeks](http://webhostinggeeks.com/) 
Note: See TracChangeset for help on using the changeset viewer.