F2P Filter: Modify the Meta Data of Imported Posts
The filter shown below allows you to modify the metadata of imported posts. This works very similarly to this filter.
NOTE: The plugin will prefix each meta key with “wprss_ftp_”. To avoid this, add an exclamation mark, “!”, at the beginning of the meta key. The plugin will automatically detect the exclamation mark, remove it, and skip adding the prefix.
NOTE: The post has already been inserted into the database at this stage.
add_filter( 'wprss_ftp_post_meta', 'my_custom_post_meta', 10, 4 );
/**
 * Exposes the meta data of a post that results from import of a feed item. 
 *
 * @param array $meta The original meta data array.
 * @param int $post_id The ID of the post, which is being processed.
 * @param int $feed_source The ID of the feed source post, which the current item is being imported by.
 * @param SimplePie_Item $feed_item The feed item, which is being imported.
 * @return array The new meta data array.
 */
function my_custom_post_meta( $meta, $post_id, $feed_source, $feed_item ) {
    // Add meta data, with "wprss_ftp_" prefix
    $meta['my_meta'] = 'some value';
    // Add meta data, without the "wprss_ftp_" prefix. Uncomment the line below and comment out the line above to use this method.
    // $meta['!my_meta'] = 'some value';
    // Check feed source
    if ( $feed_source === 51 ) {
        // Remove meta added by the plugin (NOT RECOMMENDED)
        unset( $meta['import_date'] );
    }
    
    // The feed object
    $feed = $feed_item->get_feed();
    /* @var $feed SimplePie */
    // Return the meta - IMPORTANT
    return $meta;
}
How do I add this to my site?
Follow the step-by-step instructions below to add this filter to your WordPress site.
- Copy the code you need from above.
 - Go to your WordPress site's dashboard.
 - Go to Plugins > Add New.
 - Search for Code Snippets, then install and activate the plugin.
 - Once installed and activated, go to Snippets in your dashboard menu.
 - Click on Add New.
 - Add a Title, which could be the title of this article.
 - Paste the code you copied in step 1 to the Code section.
 - Add a Description or Tags if you wish to do so. It is not required.
 - Click on Save Changes and Activate to save the filter and activate it.
  
- Or click on Save Changes to save the filter and activate it later.
 
 - Your action or filter is now stored and active on your site.