Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
<?php
function pgmb_gf_post_created($post_id, $feed, $entry, $form){
global $post_to_google_my_business_plugin;
$post_type = 'your_post_type';
// -- Do not edit after this
//If this is a different post type, abort
if($post_type != get_post_type($post_id)){
return;
}
//Make sure the snippet doesn't crash the site if the plugin is disabled or the name of the variable is changed
if(!isset($post_to_google_my_business_plugin) || !$post_to_google_my_business_plugin instanceof MBP_Plugin){
return;
}
$reflection = new ReflectionObject($post_to_google_my_business_plugin);
try{
//Make sure the metabox property actually exists
$metabox = $reflection->getProperty('metabox');
} catch (ReflectionException $ex) {
return;
}
$metabox->setAccessible(true);
$instance = $metabox->getValue($post_to_google_my_business_plugin);
//Cancel the default auto post
add_filter('mbp_autopost_before_insert_subpost', '__return_false');
$instance->save_autopost_template($post_id, get_post($post_id), false);
}
add_action( 'gform_advancedpostcreation_post_after_creation', 'pgmb_gf_post_created', 10, 4 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment