Title: [Plugin: Posts 2 Posts] Call to function error
Last modified: August 20, 2016

---

# [Plugin: Posts 2 Posts] Call to function error

 *  Resolved [brandonferens](https://wordpress.org/support/users/brandonferens/)
 * (@brandonferens)
 * [13 years, 9 months ago](https://wordpress.org/support/topic/plugin-posts-2-posts-call-to-function-error/)
 * Here is the error that I am getting. This happened upon upgrading from 1.3 to
   1.4.
 * Fatal error: Call to a member function get_object() on a non-object in /home/
   perfects/public_html/inewsource.perfectspacedev.com/wp-content/plugins/posts-
   to-posts/core/directed-type.php on line 132
 * This is happening on a custom post called Articles. Let me know if you would 
   like access to our dev environment so you can check it out yourself.
 * [http://wordpress.org/extend/plugins/posts-to-posts/](http://wordpress.org/extend/plugins/posts-to-posts/)

Viewing 15 replies - 1 through 15 (of 16 total)

1 [2](https://wordpress.org/support/topic/plugin-posts-2-posts-call-to-function-error/page/2/?output_format=md)
[→](https://wordpress.org/support/topic/plugin-posts-2-posts-call-to-function-error/page/2/?output_format=md)

 *  Plugin Author [scribu](https://wordpress.org/support/users/scribu/)
 * (@scribu)
 * [13 years, 9 months ago](https://wordpress.org/support/topic/plugin-posts-2-posts-call-to-function-error/#post-2975953)
 * Well, access to the dev environment would be good, but I’d like to try reproducing
   it locally first.
 * Please share the `p2p_register_connection_type()` call that you think is causing
   the problem.
 *  Thread Starter [brandonferens](https://wordpress.org/support/users/brandonferens/)
 * (@brandonferens)
 * [13 years, 9 months ago](https://wordpress.org/support/topic/plugin-posts-2-posts-call-to-function-error/#post-2975954)
 * I’m guessing it is one of these:
 *     ```
       p2p_register_connection_type( array('name' => 'projects_to_articles', 'from' => 'project', 'to' => 'article', 'reciprocal' => true  ) );
       p2p_register_connection_type( array('name' => 'articles_to_articles', 'from' => 'article', 'to' => 'article', 'reciprocal' => true  ) );
       p2p_register_connection_type( array('name' => 'articles_to_data-sets',  'from' => 'article', 'to' => 'data-set', 'reciprocal' => true  ) );
       ```
   
 *  [khanman225](https://wordpress.org/support/users/khanman225/)
 * (@khanman225)
 * [13 years, 9 months ago](https://wordpress.org/support/topic/plugin-posts-2-posts-call-to-function-error/#post-2975955)
 * Same problem on upgrade.
 * Here are my registration function calls:
 *     ```
       p2p_register_connection_type( array(
       		'name' => 'actors_to_tv-shows',
       		'from' => 'actors',
       		'to' => 'tv-shows',
       		'reciprocal' => true,
       		'fields' => array(
       			'character' => array('title' => 'Character', 'type' => 'text')
       		)
       	) );
   
       	p2p_register_connection_type( array(
       		'name' => 'clothing_to_actors',
       		'from' => 'clothing',
       		'to' => 'actors',
       		'reciprocal' => true
       	) );
   
       	p2p_register_connection_type( array(
       		'name' => 'clothing_to_tv-shows',
       		'from' => 'clothing',
       		'to' => 'tv-shows',
       		'reciprocal' => true
       	) );
   
       	p2p_register_connection_type( array(
       		'name' => 'clothing_to_clothing',
       		'from' => 'clothing',
       		'to' => 'clothing',
       		'reciprocal' => true
       	) );
       ```
   
 *  Plugin Author [scribu](https://wordpress.org/support/users/scribu/)
 * (@scribu)
 * [13 years, 9 months ago](https://wordpress.org/support/topic/plugin-posts-2-posts-call-to-function-error/#post-2976042)
 * I can’t reproduce the error with either connection type sets.
 * So, brandonferens, if you can give me access to your dev site, my email is mail
   AT scribu.net
 *  [FriendlyWP](https://wordpress.org/support/users/mmcginnis/)
 * (@mmcginnis)
 * [13 years, 9 months ago](https://wordpress.org/support/topic/plugin-posts-2-posts-call-to-function-error/#post-2976056)
 * Just a thought, it may be the add_action call for the register-connection function
   you’re using which causes the error. When I tried using anything other than wp_loaded:
 * `add_action( 'wp_loaded', 'my_connection_types' );`
 * that’s the error I saw. For instance when I tried
 * `add_action( 'init', 'my_connection_types' );`
 * or
 * `add_action( 'p2p_init', 'my_connection_types' );`
 * I got that error. I could be totally off-base, just thought I’d mention it in
   case it’s useful.
 *  [khanman225](https://wordpress.org/support/users/khanman225/)
 * (@khanman225)
 * [13 years, 9 months ago](https://wordpress.org/support/topic/plugin-posts-2-posts-call-to-function-error/#post-2976061)
 * [@mmcginnis](https://wordpress.org/support/users/mmcginnis/) – I still get the
   same error when using the different hooks.
 * [@scribu](https://wordpress.org/support/users/scribu/) – If I comment out the
   clothing-to-actors call then the error is gone on the edit actor page and the
   edit clothing page (but still on the edit tv shows page). Not sure if that helps.
 *  [acsnaterse](https://wordpress.org/support/users/acsnaterse/)
 * (@acsnaterse)
 * [13 years, 9 months ago](https://wordpress.org/support/topic/plugin-posts-2-posts-call-to-function-error/#post-2976100)
 * Just for the info: Got the same issue here after upgrading. Changing the hooks
   didn’t work for me either.
 * This is the code that I’m using:
 *     ```
       function uprs_connection_types() {
       	// Make sure the Posts 2 Posts plugin is active.
       	if ( !function_exists( 'p2p_register_connection_type' ) )
       		return;
   
       	p2p_register_connection_type( array(
       		'name' => 'reviews_to_products',
       		'from' => 'review',
       		'to' => 'product',
       		'reciprocal' => true
       	) );
       }
       add_action( 'p2p_init', 'uprs_connection_types' );
       ```
   
 * So, if there’s an outcome, please share 🙂
 *  Plugin Author [scribu](https://wordpress.org/support/users/scribu/)
 * (@scribu)
 * [13 years, 9 months ago](https://wordpress.org/support/topic/plugin-posts-2-posts-call-to-function-error/#post-2976102)
 * I was able to reproduce the error locally. Working on a fix.
 *  Plugin Author [scribu](https://wordpress.org/support/users/scribu/)
 * (@scribu)
 * [13 years, 9 months ago](https://wordpress.org/support/topic/plugin-posts-2-posts-call-to-function-error/#post-2976103)
 * Should be fixed in the [development version](http://downloads.wordpress.org/plugin/posts-to-posts.zip)(
   1.4.1-alpha).
 *  [acsnaterse](https://wordpress.org/support/users/acsnaterse/)
 * (@acsnaterse)
 * [13 years, 9 months ago](https://wordpress.org/support/topic/plugin-posts-2-posts-call-to-function-error/#post-2976106)
 * Yup, confirmed. Works here in 1.4.1-alpha.
 * Thanks!
 *  [Manuel Schmalstieg](https://wordpress.org/support/users/targz-1/)
 * (@targz-1)
 * [13 years, 9 months ago](https://wordpress.org/support/topic/plugin-posts-2-posts-call-to-function-error/#post-2976109)
 * Yup, I got the same issue with the 1.4 update (only in the admin interface though,
   on the public facing pages everything worked fine).
 * The 1.4.1-alpha fixed it.
 *  Thread Starter [brandonferens](https://wordpress.org/support/users/brandonferens/)
 * (@brandonferens)
 * [13 years, 9 months ago](https://wordpress.org/support/topic/plugin-posts-2-posts-call-to-function-error/#post-2976112)
 * Perfect! Thanks for the update.
 *  [Christian Denat](https://wordpress.org/support/users/yakafaucon/)
 * (@yakafaucon)
 * [13 years, 9 months ago](https://wordpress.org/support/topic/plugin-posts-2-posts-call-to-function-error/#post-2976113)
 * Great, I got the same problem.. but as I upgraded in same time Event manager 
   plugin, I was so disapointed ..
    All is working now qith the alpha !
 * Thanks
 *  [dangranata](https://wordpress.org/support/users/dangranata/)
 * (@dangranata)
 * [13 years, 8 months ago](https://wordpress.org/support/topic/plugin-posts-2-posts-call-to-function-error/#post-2976218)
 * I’m getting a strange error – which seems to be isolated to a single (local) 
   install with a custom theme. I’m fully prepared to fix my code, I’m just not 
   sure where to begin.
 * WP 3.4.1
    P2P 1.4.2-alpha2 (also happened with 1.4.1, but not previous versions)
 * Upon activation, I get a fatal error:
 * **Call to undefined function get_current_screen() in [localpath]/wp-content/plugins/
   posts-to-posts/core/url-query.php on line 27**
 * I deactivated all other plugins, same error. I did try this with a different 
   install (one that has no P2P connections yet), and there was no problem.
 * Temporarily commenting out the following lines seemed to fix the problem (lines
   12-13 in posts-to-posts/core/url-query.php):
 *     ```
       if ( is_admin() )
       			add_action( 'pre_user_query', array( __CLASS__, 'user_query' ), 9 );
       ```
   
 * But I really would rather ensure the problem won’t crop up again once we upgrade.
   I know not knowing specifics about my install will make it difficult to diagnose,
   but I’m crawling line by line through any P2P code and I can’t figure out what
   would trigger that error – so I’m hoping that it might be caused by something
   obvious (an action hooked too early?) that changed in the most recent version.
 * Thanks!
 *  Plugin Author [scribu](https://wordpress.org/support/users/scribu/)
 * (@scribu)
 * [13 years, 8 months ago](https://wordpress.org/support/topic/plugin-posts-2-posts-call-to-function-error/#post-2976219)
 * Yes, that’s really strange, since `get_current_screen()` is a core WordPress 
   function.
 * Should have started a new thread, though.

Viewing 15 replies - 1 through 15 (of 16 total)

1 [2](https://wordpress.org/support/topic/plugin-posts-2-posts-call-to-function-error/page/2/?output_format=md)
[→](https://wordpress.org/support/topic/plugin-posts-2-posts-call-to-function-error/page/2/?output_format=md)

The topic ‘[Plugin: Posts 2 Posts] Call to function error’ is closed to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/posts-to-posts_7a8e9d.svg)
 * [Posts 2 Posts](https://wordpress.org/plugins/posts-to-posts/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/posts-to-posts/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/posts-to-posts/)
 * [Active Topics](https://wordpress.org/support/plugin/posts-to-posts/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/posts-to-posts/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/posts-to-posts/reviews/)

 * 16 replies
 * 8 participants
 * Last reply from: [dangranata](https://wordpress.org/support/users/dangranata/)
 * Last activity: [13 years, 8 months ago](https://wordpress.org/support/topic/plugin-posts-2-posts-call-to-function-error/page/2/#post-2976220)
 * Status: resolved