Custom Field For Pricing

This topic contains 3 replies, has 2 voices, and was last updated by  Stephen Harris 10 years, 7 months ago.

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #7329

    Hey Stephen,

    Is the best way to add a field called “Pricing” where the event manager can enter in whether the event is “free” or “paid“, to just create a custom field and add it to each event?

    Or… is there an easier way I can add in this option so I don’t have to the event details section?

    pach16
    #7334

    Actually,

    What I would like to do is add two meta-boxes to the admin panel for events.

    • One for adding where it’s a free or paid event
    • another one to add a link to the registration form (which is on a thrid-party site)
    pach16
    #7335

    Got this so far, just need to figure out how to save it.

    function add_events_metaboxes() {
        add_meta_box('event-fee','Event Fee', 'my_metabox_fees', 'event', 'side', 'high');
        add_meta_box('registration-link','Registration Link', 'my_metabox_register_link', 'event', 'side', 'default');
    }
    add_action('add_meta_boxes','add_events_metaboxes');
    
    // Fees Meta Box
    function my_metabox_fees($fee){
      ?>
        <label>Event fee:</label>
        <input type="text" name="" value="" >
      <?php 
    }
    
    // Registration Link Meta Box
    function my_metabox_register_link($registerlink){
      ?>
        <label>Registration Link:</label> 
        <input type="text" name="" value="" >
      <?php 
    }
    
    pach16
    #7349

    To save data from a custom metabox, just use the save_post hook, and check the post type, permissions (and nonces). (See codex: http://codex.wordpress.org/Plugin_API/Action_Reference/save_post ). You’ll want to use update_post_meta() ( http://codex.wordpress.org/Function_Reference/update_post_meta) to save the data to the event, and then you can retrieve this in the templates with get_post_meta().

    Stephen Harris
Viewing 4 posts - 1 through 4 (of 4 total)
To enable me to focus on Pro customers, only users who have a valid license for the Pro add-on may post new topics or replies in this forum. If you have a valid license, please log-in or register an account using the e-mail address you purchased the license with. If you don't you can purchase one here. Or there's always the WordPress repository forum.