WordPress.org

Ready to get started?Download WordPress

Forums

Events Manager
[resolved] Copy EM_Location object fields to custom fields? (2 posts)

  1. Pete
    Member
    Posted 1 year ago #

    Hi,

    I tried to create a filter using the code below

    function custom_filter() {
    
        update_post_meta($this->post_id, 'cf_location_address', $this->location_address);
        update_post_meta($this->post_id, 'cf_location_town', $this->location_town);
        update_post_meta($this->post_id, 'cf_location_state', $this->location_state);
        update_post_meta($this->post_id, 'cf_location_postcode', $this->location_postcode);
        // print_r($this);
    }
    add_filter('em_location_save','custom_filter' );

    It's not correct, that I know but I thought it would execute my code? If I place the update_post_meta functions in to em-location.php the code work. But I need to write this as a filter.

    In my functions.php within my custom function how can I get the $this variable to print which is in the em-location.php file? I suppose from there I can write the rest of the function.

    Thanks

    http://wordpress.org/extend/plugins/events-manager/

  2. agelonwl
    Member
    Posted 1 year ago #

    you need something like

    function custom_filter($result,$EM_location) {
     update_post_meta($EM_location->post_id, .......
    }
    add_filter('em_location_save','custom_filter',1,2 );

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic