Title: Conditional related type
Last modified: August 22, 2016

---

# Conditional related type

 *  Resolved [igogra](https://wordpress.org/support/users/igogra/)
 * (@igogra)
 * [11 years, 8 months ago](https://wordpress.org/support/topic/conditional-related-type/)
 * Hi.
 * I have a site where contributors can add posts of type ‘Brand’ and ‘Invoicing
   by brand’. In the ‘Invoicing by brand’ post I have a custom field ‘Brand’ as 
   related type so it displays all Brands in the system. However I would like to
   show just the Brands which were added by the current contributor. Is there any
   way to do that?
 * Thanks.
 * [https://wordpress.org/plugins/magic-fields-2/](https://wordpress.org/plugins/magic-fields-2/)

Viewing 1 replies (of 1 total)

 *  Thread Starter [igogra](https://wordpress.org/support/users/igogra/)
 * (@igogra)
 * [11 years, 8 months ago](https://wordpress.org/support/topic/conditional-related-type/#post-5233475)
 * I just solved it.
 * I modified the plugin. In the plugin’s folder I duplicated the related_type_field
   folder. I renamed it as related_author_type_field (the folder and the php file).
   And then in related_author_type_field.php I added an ‘if’ statement to check 
   if the current user is the author inside the display_field function:
 *     ```
       public function display_field( $field, $group_index = 1, $field_index = 1 ) {
          ...
          foreach($options as $option) {
             if($option->post_author == get_current_user_id()) { // Added
                ... // Here everything that was inside the foreach
             }
          }
          ...
       }
       ```
   

Viewing 1 replies (of 1 total)

The topic ‘Conditional related type’ is closed to new replies.

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

 * 1 reply
 * 1 participant
 * Last reply from: [igogra](https://wordpress.org/support/users/igogra/)
 * Last activity: [11 years, 8 months ago](https://wordpress.org/support/topic/conditional-related-type/#post-5233475)
 * Status: resolved