[buddypress-trac] [BuddyPress Trac] #9301: Template notice not displayed for logged-out users when clicking on email unsubscribe link

buddypress-trac noreply at wordpress.org
Wed Sep 17 13:56:00 UTC 2025


#9301: Template notice not displayed for logged-out users when clicking on email
unsubscribe link
-------------------------------------------------+-------------------------
 Reporter:  r-a-y                                |       Owner:  (none)
     Type:  defect (bug)                         |      Status:  new
 Priority:  normal                               |   Milestone:  Awaiting
                                                 |  Review
Component:  Emails                               |     Version:
 Severity:  normal                               |  Resolution:
 Keywords:  dev-feedback has-screenshots has-    |
  patch needs-testing                            |
-------------------------------------------------+-------------------------

Comment (by dcavins):

 This looks good to me. Though I wonder if we could simplify the last
 if/else by adding a logged in check in the outer if condition rather than
 repeating the wp_die() code. Like:

 {{{
 if ( is_user_logged_in() && $raw_user_id && $redirect_to ) {
                 $message = sprintf(
                         '%1$s <a href="%2$s">%3$s</a>',
                         $result_msg,
                         esc_url( $redirect_to ),
                         esc_html( $unsub_msg )
                 );

                 // Template notices are only displayed on BP pages.
                 bp_core_add_message( $message );
                 bp_core_redirect( bp_members_get_user_url( $raw_user_id )
 );

                 exit;
         } else {
                 wp_die(
                         sprintf( '%1$s %2$s', esc_html( $unsub_msg ),
 esc_html( $result_msg ) ),
                         esc_html( $unsub_msg ),
                         array(
                                 'link_url'  => esc_url( home_url() ),
                                 'link_text' => esc_html__( 'Go to
 website\'s home page.', 'buddypress' ),
                         )
                 );
         }
 }}}

 Am I missing a case? Thanks again for coming up with a solution to this
 problem.

-- 
Ticket URL: <https://buddypress.trac.wordpress.org/ticket/9301#comment:15>
BuddyPress Trac <http://buddypress.org/>
BuddyPress Trac


More information about the buddypress-trac mailing list