Skip to:
Content

BuddyPress.org

Ticket #4676: 4676.01.patch

File 4676.01.patch, 2.8 KB (added by r-a-y, 11 years ago)
  • bp-members/bp-members-functions.php

     
    17261726        // the user exists; now do a check to see if the user has activated their account or not
    17271727        // NOTE: this is only applicable for single site WordPress installs!
    17281728        // if unactivated, stop the login now!
    1729         if ( is_a( $user, 'WP_User' ) && 2 == $user->user_status )
    1730                 return new WP_Error( 'bp_account_not_activated', __( '<strong>ERROR</strong>: Your account has not been activated. Check your email for the activation link.', 'buddypress' ) );
     1729        if ( is_a( $user, 'WP_User' ) && 2 == $user->user_status ) {
     1730                $resend_url_params = array(
     1731                        'action' => 'bp-resend-activation',
     1732                        'user'   => $user->user_login,
     1733                );
     1734
     1735                $resend_url = wp_nonce_url(
     1736                        add_query_arg( $resend_url_params, wp_login_url() ),
     1737                        'bp-resend-activation'
     1738                );
     1739
     1740                $resend_string = '<br /><br />' .  sprintf( __( 'If you have not received an email yet, <a href="%s">click here to resend it</a>.', 'buddypress' ), $resend_url );
     1741
     1742                return new WP_Error( 'bp_account_not_activated', __( '<strong>ERROR</strong>: Your account has not been activated. Check your email for the activation link.', 'buddypress' ) . $resend_string );
     1743        }
    17311744
    17321745        // user has activated their account! all clear!
    17331746        return $user;
     
    17351748add_filter( 'authenticate', 'bp_core_signup_disable_inactive', 30 );
    17361749
    17371750/**
     1751 * On the login screen, resends the activation email for a user.
     1752 *
     1753 * @since BuddyPress (2.0.0)
     1754 *
     1755 * @see bp_core_signup_disable_inactive()
     1756 */
     1757function bp_members_login_resend_activation_email() {
     1758        global $error;
     1759
     1760        if ( empty( $_GET['user'] ) || empty( $_GET['_wpnonce'] ) ) {
     1761                return;
     1762        }
     1763
     1764        // verify nonce
     1765        if ( ! wp_verify_nonce( $_GET['_wpnonce'], 'bp-resend-activation' ) ) {
     1766                die( 'Security check' );
     1767        }
     1768
     1769        // fetch the signup ID
     1770        // note: this is different than the user ID
     1771        $signup_query = BP_Signup::get( array(
     1772                'user_login' => $_GET['user']
     1773        ) );
     1774
     1775        // no match, stop now!
     1776        if ( empty( $signup_query['signups'][0] ) ) {
     1777                return;
     1778        }
     1779
     1780        // resend the activation email
     1781        // also updates the 'last sent' and '# of emails sent' values
     1782        $resend = BP_Signup::resend( array( $signup_query['signups'][0]->signup_id ) );
     1783
     1784        // add feedback message
     1785        if ( ! empty( $resend['errors'] ) ) {
     1786                $error = __( '<strong>ERROR</strong>: Your account has already been activated.', 'buddypress' );
     1787        } else {
     1788                $error = __( 'Activation email resent!', 'buddypress' );
     1789        }
     1790}
     1791add_action( 'login_form_bp-resend-activation', 'bp_members_login_resend_activation_email' );
     1792
     1793/**
    17381794 * Kill the wp-signup.php if custom registration signup templates are present
    17391795 */
    17401796function bp_core_wpsignup_redirect() {