Title: Context not working for custom fields
Last modified: April 9, 2018

---

# Context not working for custom fields

 *  Resolved [missbritt](https://wordpress.org/support/users/missbritt/)
 * (@missbritt)
 * [8 years, 1 month ago](https://wordpress.org/support/topic/context-not-working-for-custom-fields/)
 * Adding the event ID in context does not make the custom fields appear on the 
   indicated event add to cart form. Instead, it removes it entirely.
 * This is how I had the code:
 *     ```
       add_filter( 'mt_custom_fields', 'create_custom_fields', 10, 1 );
       function create_custom_fields( $array ) {
       	// Other fields: sanitize callback; input type; input values; display_callback
       		$array['golf_partners'] = array(
       		'title'=>"FOR GOLFERS - Golf Parnters:",
       		'sanitize_callback'=>'sanitize_callback',
       		'display_callback'=>'display_callback',
       		'input_type'=>'Text',
       		'context'=> '2',
   
   
       	);
       	$array['game_choice'] = array( 
       		'title'=>"FOR GAMES - Choice of Game", 
       		'sanitize_callback'=>'sanitize_callback', 
       		'display_callback'=>'display_callback',
       		'input_type'=>'select',
       		'input_values'=>array( 'None', 'Bridge', 'Mahjong', 'Canasta' ),
       		'context'=> '2',
   
       	);
       		$array['game_partnerss'] = array(
       		'title'=>"Game Partners:",
       		'sanitize_callback'=>'sanitize_callback',
       		'display_callback'=>'display_callback',
       		'input_type'=>'Text',
       		'context'=> '2',
   
       	);
       ```
   
 * 2 is what’s listed as ID in My Calendar events.
 * If I remove the context line entirely or replace the 2 with ‘global’, the fields
   show up on all tickets pages.

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

 *  Plugin Author [Joe Dolson](https://wordpress.org/support/users/joedolson/)
 * (@joedolson)
 * [8 years, 1 month ago](https://wordpress.org/support/topic/context-not-working-for-custom-fields/#post-10166055)
 * I’m guessing that you’re not using the right ID. If ‘2’ is the My Calendar ID
   for the event, then that’s separate from the My Tickets ID for the event. If 
   you look in the My Tickets configuration block in the event, you’ll see a shortcode
   displayed that looks like `[ticket event="234"]`. That number is the event ID
   for My Tickets.
 *  Thread Starter [missbritt](https://wordpress.org/support/users/missbritt/)
 * (@missbritt)
 * [8 years, 1 month ago](https://wordpress.org/support/topic/context-not-working-for-custom-fields/#post-10178426)
 * I can’t believe I didn’t come up with that in all my digging. THANK YOU!!!!

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

The topic ‘Context not working for custom fields’ is closed to new replies.

 * ![](https://ps.w.org/my-tickets/assets/icon-256x256.png?rev=1097581)
 * [My Tickets - Accessible Event Ticketing](https://wordpress.org/plugins/my-tickets/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/my-tickets/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/my-tickets/)
 * [Active Topics](https://wordpress.org/support/plugin/my-tickets/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/my-tickets/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/my-tickets/reviews/)

## Tags

 * [context](https://wordpress.org/support/topic-tag/context/)
 * [custom fields](https://wordpress.org/support/topic-tag/custom-fields/)
 * [mytickets](https://wordpress.org/support/topic-tag/mytickets/)

 * 2 replies
 * 2 participants
 * Last reply from: [missbritt](https://wordpress.org/support/users/missbritt/)
 * Last activity: [8 years, 1 month ago](https://wordpress.org/support/topic/context-not-working-for-custom-fields/#post-10178426)
 * Status: resolved