scribu / wp-posts-to-posts

Efficient many-to-many connections between posts, pages, custom post types, users.
http://wordpress.org/plugins/posts-to-posts/
974 stars 260 forks source link

Users are not showing in the admin_column #581

Open OlaIola opened 10 months ago

OlaIola commented 10 months ago

Plugin version is 1.7.2

       p2p_register_connection_type(
         array(
            'name'           => 'event_to_user',
            'from'           => 'event',
            'to'             => 'user',
            'admin_column'   => 'from',
            'to_query_vars' => array( 'role' => 'editor' )
         )
      );

Trying to show connected users in an admin column for a post type is not succeeded because the object don't have what is required by function:

/wp-content/plugins/posts-to-posts/vendor/scribu/lib-posts-to-posts/util.php:123

/** @internal */
function _p2p_get_other_id( $item ) {
   if ( $item->ID == $item->p2p_from )
      return $item->p2p_to;

   if ( $item->ID == $item->p2p_to )
      return $item->p2p_from;

   trigger_error( "Corrupted data for item $inner_item->ID", E_USER_WARNING );
}

And resulting in:

PHP Notice:  Undefined variable: inner_item in /var/www/html/wp-content/plugins/posts-to-posts/vendor/scribu/lib-posts-to-posts/util.php on line 123
PHP Notice:  Trying to get property 'ID' of non-object in /var/www/html/wp-content/plugins/posts-to-posts/vendor/scribu/lib-posts-to-posts/util.php on line 123
PHP Warning:  Corrupted data for item  in /var/www/html/wp-content/plugins/posts-to-posts/vendor/scribu/lib-posts-to-posts/util.php on line 123