Created
July 29, 2012 13:35
-
-
Save seebz/3198841 to your computer and use it in GitHub Desktop.
Missing bbp template file
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_filter( 'posts_join', function($join, $wp_query) { | |
global $wpdb; | |
if ( $wp_query->get('post_type') == 'topic' && $wp_query->get('participant') ) { | |
$join .= " | |
LEFT OUTER JOIN ( | |
SELECT DISTINCT(post_parent) | |
FROM {$wpdb->posts} | |
WHERE post_type = 'reply' | |
AND post_author = '{$wp_query->get('participant')}' | |
) p_replies ON p_replies.post_parent = {$wpdb->posts}.ID | |
"; | |
} | |
return $join; | |
}, 10, 2); | |
add_filter( 'posts_where', function($where, $wp_query) { | |
global $wpdb; | |
if ( $wp_query->get('post_type') == 'topic' && $wp_query->get('participant') ) { | |
$where .= " AND (p_replies.post_parent IS NOT NULL)"; | |
} | |
return $where; | |
}, 10, 2); | |
function _bbp_get_user_topics_replied( $user_id = 0 ) { | |
// Validate user | |
$user_id = bbp_get_user_id( $user_id ); | |
if ( empty( $user_id ) ) | |
return false; | |
// Query defaults | |
$default_query = array( | |
'participant' => $user_id, | |
'show_stickies' => false, | |
'order' => 'DESC', | |
); | |
// Try to get the topics | |
$query = bbp_has_topics( $default_query ); | |
if ( empty( $query ) ) | |
return false; | |
return apply_filters( '_bbp_get_user_topics_replied', $query, $user_id ); | |
} | |
?> | |
<?php //do_action( 'bbp_template_before_user_topics_created' ); ?> | |
<?php //bbp_set_query_name( 'bbp_user_profile_topics_created' ); ?> | |
<div id="bbp-author-topics-started" class="bbp-author-topics-started"> | |
<h2 class="entry-title">Réponses</h2> | |
<div class="bbp-user-section"> | |
<?php //if ( bbp_get_user_topics_started() ) : ?> | |
<?php if ( _bbp_get_user_topics_replied() ) : ?> | |
<?php bbp_get_template_part( 'pagination', 'topics' ); ?> | |
<?php bbp_get_template_part( 'loop', 'topics' ); ?> | |
<?php bbp_get_template_part( 'pagination', 'topics' ); ?> | |
<?php else : ?> | |
<p><?php bbp_is_user_home() ? "Vous n'avez pas encore créé de message" : "Ce membre n'a pas encore créé de message"; ?></p> | |
<?php endif; ?> | |
</div> | |
</div><!-- #bbp-author-topics-started --> | |
<?php //bbp_reset_query_name(); ?> | |
<?php //do_action( 'bbp_template_after_user_topics_created' ); ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment