WordPress.org

Plugin Directory

Changeset 605064


Ignore:
Timestamp:
09/28/12 07:44:13 (19 months ago)
Author:
picklewagon
Message:

add filters for all messages in plugin

Location:
new-user-approve/branches/1.4
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • new-user-approve/branches/1.4/new-user-approve.php

    r605031 r605064  
    6363 
    6464        // Filters 
    65         add_filter('registration_errors', array( $this, 'show_user_message'), 10, 1); 
     65        add_filter('registration_errors', array( $this, 'show_user_pending_message'), 10, 1); 
    6666        add_filter('login_message', array( $this, 'welcome_user')); 
    6767        add_filter( 'wp_authenticate_user', array( $this, 'authenticate_user' ), 10, 2); 
     
    279279                 
    280280                $message = apply_filters( 'new_user_approve_request_approval_message', $message, $user_login, $user_email ); 
     281                 
     282                $subject = sprintf( __('[%s] User Approval', $this->plugin_id ), get_option( 'blogname' ) ); 
     283                $subject = apply_filter( 'new_user_approve_request_approval_subject', $subject ); 
    281284 
    282285                // send the mail 
    283                 wp_mail(get_option('admin_email'), sprintf(__('[%s] User Approval', $this->plugin_id), get_option('blogname')), $message); 
     286                wp_mail( get_option( 'admin_email' ), $subject, $message ); 
    284287 
    285288                // create the user 
     
    323326        $message .= get_option('siteurl') . "/wp-login.php\r\n"; 
    324327 
     328        $message = apply_filters( 'new_user_approve_approve_user_message', $message, $user ); 
     329         
     330        $subject = sprintf( __('[%s] Registration Approved', $this->plugin_id ), get_option( 'blogname' ) ); 
     331        $subject = apply_filters( 'new_user_approve_approve_user_subject', $subject ); 
     332         
    325333        // send the mail 
    326         @wp_mail($user_email, sprintf(__('[%s] Registration Approved', $this->plugin_id), get_option('blogname')), $message); 
     334        @wp_mail( $user_email, $subject, $message ); 
    327335 
    328336        // change usermeta tag in database to approved 
    329         update_user_meta($user->ID, 'pw_user_status', 'approved'); 
     337        update_user_meta( $user->ID, 'pw_user_status', 'approved' ); 
    330338    } 
    331339 
     
    342350        // format the message 
    343351        $message = sprintf(__('You have been denied access to %s', $this->plugin_id), get_option('blogname')); 
     352        $message = apply_filters( 'new_user_approve_deny_user_message', $message, $user ); 
     353         
     354        $subject = sprintf( __('[%s] Registration Denied', $this->plugin_id ), get_option( 'blogname' ) ); 
     355        $subject = apply_filters( 'new_user_approve_deny_user_subject', $subject ); 
    344356 
    345357        // send the mail 
    346         @wp_mail($user_email, sprintf(__('[%s] Registration Denied', $this->plugin_id), get_option('blogname')), $message); 
     358        @wp_mail( $user_email, $subject, $message ); 
    347359 
    348360        // change usermeta tag in database to denied 
     
    351363 
    352364    /** 
    353      * @desc display a message to the user if they have not been approved 
    354      */ 
    355     public function show_user_message($errors) { 
     365     * Display a message to the user after they have registered 
     366     */ 
     367    public function show_user_pending_message($errors) { 
     368        // if there is an error already, let it do it's thing 
    356369        if ( $errors->get_error_code() ) 
    357370            return $errors; 
     
    359372        $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)); 
    360373        $message .= sprintf(__('You will receive an email with instructions on what you will need to do next. Thanks for your patience.', $this->plugin_id)); 
    361  
    362         $errors->add('registration_required', $message, 'message'); 
    363  
    364         if (function_exists('login_header')) { 
    365             login_header(__('Pending Approval', $this->plugin_id), '<p class="message register">' . __("Registration successful.", $this->plugin_id) . '</p>', $errors); 
    366         } 
    367  
    368         echo "<body></html>"; 
    369         exit(); 
     374        $message = apply_filters( 'new_user_approve_pending_message', $message ); 
     375 
     376        $errors->add( 'registration_required', $message, 'message' ); 
     377 
     378        $success_message = __( 'Registration successful.', $this->plugin_id ); 
     379        $success_message = apply_filters( 'new_user_approve_registration_message', $success_message ); 
     380         
     381        if ( function_exists( 'login_header' ) ) { 
     382            login_header( __('Pending Approval', $this->plugin_id ), '<p class="message register">' . $success_message . '</p>', $errors ); 
     383            login_footer(); 
     384             
     385            // an exit is necessay here so the normal process for user registration doesn't happen 
     386            exit(); 
     387        } 
    370388    } 
    371389 
     
    412430    public function welcome_user($message) { 
    413431        if (!isset($_GET['action'])) { 
    414             $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')); 
    415             $message .= '<p class="message">' . $inside . '</p>'; 
     432            $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')); 
     433            $welcome = apply_filters( 'new_user_approve_welcome_message', $welcome ); 
     434             
     435            $message .= '<p class="message">' . $welcome . '</p>'; 
    416436        } 
    417437 
    418438        if ( isset( $_GET['action'] ) && $_GET['action'] == 'register' && !$_POST ) { 
    419             $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)); 
    420             $message .= '<p class="message">' . $inside . '</p>'; 
     439            $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)); 
     440            $instructions = apply_filters( 'new_user_approve_register_instructions', $instructions ); 
     441             
     442            $message .= '<p class="message">' . $instructions . '</p>'; 
    421443        } 
    422444 
     
    447469        switch ( $status ) { 
    448470            case 'pending': 
    449                 $message = new WP_Error('pending_approval', __('<strong>ERROR</strong>: Your account is still pending approval.')); 
     471                $pending_message = __( '<strong>ERROR</strong>: Your account is still pending approval.' ); 
     472                $pending_message = apply_filters( 'new_user_approve_pending_error', $pending_message ); 
     473                 
     474                $message = new WP_Error( 'pending_approval', $pending_message ); 
    450475                break; 
    451476            case 'denied': 
    452                 $message = new WP_Error('denied_access', __('<strong>ERROR</strong>: Your account has been denied access to this site.')); 
     477                $denied_message = __( '<strong>ERROR</strong>: Your account has been denied access to this site.' ); 
     478                $denied_message = apply_filters( 'new_user_approve_denied_error', $denied_message ); 
     479                 
     480                $message = new WP_Error( 'denied_access', $denied_message ); 
    453481                break; 
    454482            case 'approved': 
  • new-user-approve/branches/1.4/readme.txt

    r605031 r605064  
    5454 
    5555= 1.4 = 
    56 * add *new_user_approve_user_status* filter 
    57 * add *new_user_approve_request_approval_message* filter 
     56* add filters 
    5857 
    5958= 1.3.5 = 
     
    154153* *new_user_approve_user_status* - modify the list of users shown in the tables 
    155154* *new_user_approve_request_approval_message* - modify the request approval message 
     155* *new_user_approve_request_approval_subject* - modify the request approval subject 
     156* *new_user_approve_approve_user_message* - modify the user approval message 
     157* *new_user_approve_approve_user_subject* - modify the user approval subject 
     158* *new_user_approve_deny_user_message* - modify the user denial message 
     159* *new_user_approve_deny_user_subject* - modify the user denial subject 
     160* *new_user_approve_pending_message* - modify message user sees after registration 
     161* *new_user_approve_registration_message* - modify message after a successful registration 
     162* *new_user_approve_register_instructions* - modify message that appears on registration screen 
     163* *new_user_approve_pending_error* - error message shown to pending users when attempting to log in 
     164* *new_user_approve_denied_error* - error message shown to denied users when attempting to log in 
    156165 
    157166= Translations = 
Note: See TracChangeset for help on using the changeset viewer.