Skip to:
Content

BuddyPress.org

Ticket #7349: 7349.2.patch

File 7349.2.patch, 2.8 KB (added by dcavins, 8 years ago)

If the user is already logged in, don't stop by the login screen.

  • src/bp-core/bp-core-actions.php

    diff --git a/src/bp-core/bp-core-actions.php b/src/bp-core/bp-core-actions.php
    index d8fc1d6..05786b3 100644
    a b add_action( 'bp_activation', 'bp_add_activation_redirect' ); 
    117117
    118118// Email unsubscribe.
    119119add_action( 'bp_get_request_unsubscribe', 'bp_email_unsubscribe_handler' );
     120
     121// Login screen pass-through for currently logged-in members.
     122add_action( 'login_init', 'bp_login_redirector', 1 );
  • src/bp-core/bp-core-functions.php

    diff --git a/src/bp-core/bp-core-functions.php b/src/bp-core/bp-core-functions.php
    index 5dae2bc..32d3460 100644
    a b function bp_email_get_unsubscribe_link( $args ) { 
    37753775function bp_email_get_salt() {
    37763776        return bp_get_option( 'bp-emails-unsubscribe-salt', null );
    37773777}
     3778
     3779/**
     3780 * Login redirector.
     3781 *
     3782 * If a link is not publicly available, we can send members from external
     3783 * locations, like following links in an email, through the login screen.
     3784 *
     3785 * If a user clicks on this link and is already logged in, we should attempt
     3786 * to redirect the user to the authorized content instead of forcing the user
     3787 * to re-authenticate.
     3788 *
     3789 * @since 2.9.0
     3790 */
     3791function bp_login_redirector() {
     3792        // Redirect links must include the `redirect_to` and `auth` parameters.
     3793        if ( empty( $_GET['redirect_to'] ) || empty( $_GET['auth'] ) ) {
     3794                return;
     3795        }
     3796
     3797        /*
     3798         * If the user is already logged in,
     3799         * skip the login form and redirect them to the content.
     3800         */
     3801        if ( bp_loggedin_user_id() ) {
     3802                wp_safe_redirect( esc_url_raw( $_GET['redirect_to'] ) );
     3803                exit;
     3804        }
     3805}
     3806 No newline at end of file
  • src/bp-messages/bp-messages-functions.php

    diff --git a/src/bp-messages/bp-messages-functions.php b/src/bp-messages/bp-messages-functions.php
    index 4e78ea6..1341ee0 100644
    a b function messages_notification_new_message( $raw_args = array() ) { 
    603603                        'notification_type' => 'messages-unread',
    604604                );
    605605
     606                // Send the user to the message thread via the login screen.
     607                $message_url = add_query_arg(
     608                        array(
     609                                'action'      => 'bpnoaccess',
     610                                'auth'        => 1,
     611                                'redirect_to' => urlencode( bp_core_get_user_domain( $recipient->user_id ) . bp_get_messages_slug() . '/view/' . $thread_id . '/' )
     612                        ),
     613                        wp_login_url()
     614                );
     615
    606616                $args = array(
    607617                        'tokens' => array(
    608618                                'usermessage' => wp_strip_all_tags( stripslashes( $message ) ),
    609                                 'message.url' => esc_url( bp_core_get_user_domain( $recipient->user_id ) . bp_get_messages_slug() . '/view/' . $thread_id . '/' ),
     619                                'message.url' => esc_url( $message_url ),
    610620                                'sender.name' => $sender_name,
    611621                                'usersubject' => sanitize_text_field( stripslashes( $subject ) ),
    612622                                'unsubscribe' => esc_url( bp_email_get_unsubscribe_link( $unsubscribe_args ) ),