Display pages only for connected user
-
Hello,
First of all thank you scribu for an awesome plugin!
I’ve looked at the wiki and browsed through support topics but I can’t seem to get this to work.
I am using Posts 2 Users and managed to connect users to pages where they are linked to category: presentation. When a user logs in, I want them to see a list of pages they are connected to.
So far everything seems to work fine, except all users see the same list when they login. I am unable to filter according to the own user’s connections. What am I doing wrong?
function my_connection_types() { p2p_register_connection_type( array( 'name' => 'multiple_authors', 'from' => 'page', 'to' => 'user', ) );}
I set this up to work only with my showcase template:
p2p_register_connection_type( array( 'id' => 'landing2page', 'from' => 'page', 'from_query_vars' => array( 'meta_key' => '_wp_page_template', 'meta_value' => 'showcase.php' ), 'to' => 'user', 'title' => 'Connect Users' ) );
I’m using a shortcode called [mypresentations]:
function get_mypresentations() { // Find connected posts $connected = new WP_Query( array( 'connected_type' => 'landing2page', 'connected_items' => $user, 'suppress_filters' => false, 'nopaging' => true, 'category' => 'presentation', ) ); // Display connected posts if ( $connected->have_posts() ) : ?> <h3>Related posts:</h3> <ul> <?php while ( $connected->have_posts() ) : $connected->the_post(); ?> <li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li> <?php endwhile; ?> </ul> <?php // Prevent weirdness wp_reset_postdata(); endif; } add_shortcode( 'mypresentations', 'get_mypresentations' );
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
- The topic ‘Display pages only for connected user’ is closed to new replies.