wp-posts-to-posts icon indicating copy to clipboard operation
wp-posts-to-posts copied to clipboard

Users are not showing in the admin_column

Open OlaIola opened this issue 1 year ago • 0 comments

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

OlaIola avatar Nov 27 '23 12:11 OlaIola