Title: [Plugin: Posts 2 Posts] Cannot access protected variables in filter passed arguments
Last modified: August 20, 2016

---

# [Plugin: Posts 2 Posts] Cannot access protected variables in filter passed arguments

 *  Resolved [Georgi Popov](https://wordpress.org/support/users/magadanski_uchen/)
 * (@magadanski_uchen)
 * [14 years, 7 months ago](https://wordpress.org/support/topic/plugin-posts-2-posts-cannot-access-protected-variables-in-filter-passed-arguments/)
 * I needed to modify the arguments for the box rendering and tried doing so using
   the “p2p_connectable_args” filter, however the second argument passed (the instance
   of the P2P_Directed_Connection_Type object itself) has all of its variables set
   to protected (and it’s ctype property also does), so this whole argument doesn’t
   seem to do anything at all. The same issue would apply to the “p2p_connected_args”
   filter as well.
 * I managed to modify the arguments by using some of the global variables in WordPress(
   global $post, and some of the existing arguments), however I believe this is 
   an issue that need to be taken into consideration, as in other cases there might
   not be alternatives.
 * [http://wordpress.org/extend/plugins/posts-to-posts/](http://wordpress.org/extend/plugins/posts-to-posts/)

Viewing 3 replies - 1 through 3 (of 3 total)

 *  Plugin Author [scribu](https://wordpress.org/support/users/scribu/)
 * (@scribu)
 * [14 years, 7 months ago](https://wordpress.org/support/topic/plugin-posts-2-posts-cannot-access-protected-variables-in-filter-passed-arguments/#post-2382205)
 * The args are protected, but you can access them directly via a [magic method](http://www.php.net/manual/en/language.oop5.overloading.php#language.oop5.overloading.members):
 * So, instead of `$ctype->args['some_arg']` you can just do `$ctype->some_arg`.
 *  Thread Starter [Georgi Popov](https://wordpress.org/support/users/magadanski_uchen/)
 * (@magadanski_uchen)
 * [14 years, 6 months ago](https://wordpress.org/support/topic/plugin-posts-2-posts-cannot-access-protected-variables-in-filter-passed-arguments/#post-2382284)
 * The thing is that the cytpe object is protected itself, so it cannot be accessed.
   So everything that’s left to use is just the following properties: direction,
   cardinality and other_cardinality.
    Some get_ctype() method would really be a
   nice feature for the P2P_Directed_Connection_Type class for the next version.
   I guess that then there will no problems at all.
 *  Plugin Author [scribu](https://wordpress.org/support/users/scribu/)
 * (@scribu)
 * [14 years, 6 months ago](https://wordpress.org/support/topic/plugin-posts-2-posts-cannot-access-protected-variables-in-filter-passed-arguments/#post-2382286)
 * Like I said, you can access these properties through the magic method. It will
   cascade to the P2P_Connection_Type instance. Just try it.
 * Also, there’s already a method for getting the instance itself:
 * `$ctype->lose_direction()`

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘[Plugin: Posts 2 Posts] Cannot access protected variables in filter passed
arguments’ 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/)

 * 3 replies
 * 2 participants
 * Last reply from: [scribu](https://wordpress.org/support/users/scribu/)
 * Last activity: [14 years, 6 months ago](https://wordpress.org/support/topic/plugin-posts-2-posts-cannot-access-protected-variables-in-filter-passed-arguments/#post-2382286)
 * Status: resolved