Skip to:
Content
Pages
Categories
Search
Top
Bottom

Retrieving posts connected to a user


  • Shaun McMillan
    Participant

    @shaunmcmillan

    Using the Post-to-Posts plugin, I’m trying to display all the posts connected to the user on the buddypress member profile. The custom post-type is named, “badges.”

    The loop shows all of the connected posts to all users or none at all, but I want it to display only the posts connected to User A on User A’s profile page.

    Am I using bp->displayed_user correctly or is there something else I should use?

    Here’s the code,
    // Assign badge to user meta using Post-to-Posts Plugin
    function my_connection_types() {
    p2p_register_connection_type( array(
    'name' => 'multiple_authors',
    'from' => 'badge',
    'to' => 'user',
    //'to_query_vars' => array( 'role' => 'editor, author' )
    ) );
    }
    add_action( 'p2p_init', 'my_connection_types' );


    function display_custom_usermeta() { ?>

    displayed_user->id, 'level', true); $period = get_user_meta($bp->displayed_user->id, 'period', true);
    $painting = get_user_meta($bp->displayed_user->id, 'painting', true);
    ?>

    has reached status.

    Badges:

    displayed_user->id);
    $connected = new WP_Query( array(
    'connected_type' => 'multiple_authors',
    'connected_items' => $user,
    'suppress_filters' => false,
    'nopaging' => true,
    ) );

    // Display connected badges
    if ( $connected->have_posts() ) :
    ?>
    Badges:

    have_posts() ) : $connected->the_post(); ?>
    <a href="">

    <?php
    }

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘Retrieving posts connected to a user’ is closed to new replies.
Skip to toolbar