• Hi, i use the custum fields extension and it works fine. But i’d like to restrict for some events…

    I see that i have to change:

    ‘context’ => ‘global’ in ‘context’ => ‘custom’

    but where i have to insert the event’s id? Is it possible to restric to a one o more categories? which syntax?

    Thank you for your job!

Viewing 7 replies - 1 through 7 (of 7 total)
  • Plugin Author Joe Dolson

    (@joedolson)

    The context attribute accepts ‘global’, which is also the default value, to set it as valid for all items. You can instead pass an event ID or an array of event IDs to limit to events.

    There’s also a filter mt_apply_custom_field_rules that can be used to write a custom function that determines whether a field should show.

    Filter documentation

    Thread Starter wibe84

    (@wibe84)

    Thank you for the reply, but I have a question: I wrote ‘context’ => ‘460’
    where 460 is the ID event…but now I’m not able to see the custom field…

    Plugin Author Joe Dolson

    (@joedolson)

    Can you share a link?

    Thread Starter wibe84

    (@wibe84)

    This is the link, you can find the widget calendar: https://www.bibliosestoragazzi.it/

    This is my code:

     * Add a second custom field by adding more values to the array
     */
    $array['choose_seats'] = array(
        'title'             => 'Età precisa - SOLO EVENTI BAMBINI E RAGAZZI:',
        'sanitize_callback' => 'custom_sanitize_callback',
        'display_callback'  => 'custom_display_callback',
        'input_type'        => 'text',
        'context'           => 'global'
    );
    
    return $array;
    
    }
    
    

    I’d like to change “global” in a specific id event…

    Plugin Author Joe Dolson

    (@joedolson)

    Passing the ID as a string in the ‘context’ argument works for me, so I’m wondering if you have the wrong ID value? Where did you get it from?

    You should be using the ID that’s shown in the My Tickets block in your calendar with the shortcode preview. It won’t be the visible ID for the calendar event.

    Thread Starter wibe84

    (@wibe84)

    Ok, the problem was that i use wrong ID value. Thank you for the solution!

    Other question: how can I add more ID?

    Plugin Author Joe Dolson

    (@joedolson)

    What do you mean by adding more ID? Do you mean to the context attribute, or do you mean adding additional events? You’d add additional IDs to the context attribute as an array of IDs, e.g.

    'context' => [ 21,25,32,240 ]

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Custom fields ‘context’ => ‘sustom’’ is closed to new replies.