Support

Account

Home Forums Front-end Issues Relationship field in BBpress forum post Reply To: Relationship field in BBpress forum post

  • Solved my own question playing off @jaybuys. Since the relationship field on all user edit screens (wp/bbp) all we need to do is call it on the profile page. I have hooked into the after the user profile and am showing the related posts.

    add_action('bbp_template_after_user_profile', 'bbp_show_extra_fields');
    function bbp_show_extra_fields() {
    	$topic_id = get_user_by( 'slug', get_query_var( 'author_name' ) );
    
    	if ( function_exists('get_field') && get_field('relationship_field', $topic_id) ) {
    		$related_posts = get_field('relationship_field', $topic_id);
    
    	    foreach ($related_posts as $related_post) {
    			if (get_post_status( $related_post) == 'publish') {
    	        	echo '<a href="' . get_permalink( $related_post) . '" class="btn">' . get_the_title( $related_post) . '</a>';
    			}
    	    }
    	}
    }