Skip to:
Content

bbPress.org

Ticket #2381: user-exists.diff

File user-exists.diff, 2.7 KB (added by jondavidjohn, 8 years ago)

Protect topic and reply author link calls from non-existant users

  • includes/replies/template-tags.php

    diff --git includes/replies/template-tags.php includes/replies/template-tags.php
    index ed70d60..2bb791c 100644
    function bbp_reply_author_link( $args = '' ) { 
    10981098                        // Link class
    10991099                        $link_class = ' class="bbp-author-' . $r['type'] . '"';
    11001100
    1101                         // Add links if not anonymous
     1101                        // Add links if not anonymous and existing user
    11021102                        if ( empty( $anonymous ) && bbp_user_has_profile( bbp_get_reply_author_id( $reply_id ) ) ) {
    11031103
    11041104                                // Assemble the links
    function bbp_reply_author_url( $reply_id = 0 ) { 
    11561156        function bbp_get_reply_author_url( $reply_id = 0 ) {
    11571157                $reply_id = bbp_get_reply_id( $reply_id );
    11581158
    1159                 // Check for anonymous user
    1160                 if ( !bbp_is_reply_anonymous( $reply_id ) ) {
     1159                // Check for anonymous or non-existant user
     1160                if ( !bbp_is_reply_anonymous( $reply_id ) && bbp_user_has_profile( bbp_get_reply_author_id( $reply_id ) ) ) {
    11611161                        $author_url = bbp_get_user_profile_url( bbp_get_reply_author_id( $reply_id ) );
    11621162                } else {
    11631163                        $author_url = get_post_meta( $reply_id, '_bbp_anonymous_website', true );
  • includes/topics/template-tags.php

    diff --git includes/topics/template-tags.php includes/topics/template-tags.php
    index 2a51a5c..2b90d38 100644
    function bbp_topic_author_url( $topic_id = 0 ) { 
    14831483        function bbp_get_topic_author_url( $topic_id = 0 ) {
    14841484                $topic_id = bbp_get_topic_id( $topic_id );
    14851485
    1486                 // Check for anonymous user
    1487                 if ( !bbp_is_topic_anonymous( $topic_id ) ) {
     1486                // Check for anonymous or non-existant user
     1487                if ( !bbp_is_topic_anonymous( $topic_id ) && bbp_user_has_profile( bbp_get_topic_author_id( $topic_id ) ) ) {
    14881488                        $author_url = bbp_get_user_profile_url( bbp_get_topic_author_id( $topic_id ) );
    14891489                } else {
    14901490                        $author_url = get_post_meta( $topic_id, '_bbp_anonymous_website', true );
  • includes/users/template-tags.php

    diff --git includes/users/template-tags.php includes/users/template-tags.php
    index 014db80..25c2fac 100644
    function bbp_author_link( $args = '' ) { 
    14211421
    14221422                        // Assemble some link bits
    14231423                        $link_title = !empty( $r['link_title'] ) ? ' title="' . $r['link_title'] . '"' : '';
    1424                         $author_url = bbp_get_user_profile_url( $user_id );
    14251424                        $anonymous  = bbp_is_reply_anonymous( $r['post_id'] );
    14261425
    14271426                        // Get avatar
    function bbp_author_link( $args = '' ) { 
    14361435
    14371436                        // Add links if not anonymous
    14381437                        if ( empty( $anonymous ) && bbp_user_has_profile( $user_id ) ) {
     1438                                $author_url = bbp_get_user_profile_url( $user_id );
    14391439                                foreach ( $author_links as $link_text ) {
    14401440                                        $author_link[] = sprintf( '<a href="%1$s"%2$s>%3$s</a>', $author_url, $link_title, $link_text );
    14411441                                }