Running Action Hook on Frontend Post

This topic contains 2 reply and 2 voices, and was last updated by djhaystack 10 years, 9 months ago
Viewing 2 Posts - 1 through 2 (of 2 total)
Author Posts
July 15, 2013 at 4:34 am 5961
djhaystack I'm sure this is simple stuff but I still haven't gotten comfortable with action hooks. I have a plugin that generates a featured image from a youtube url in a custom field. It works perfectly when a post is published from the backend, but doesn't run when I use the frontend editor. I'm assuming this can be enabled using an action hook, so I'm wondering if somebody can give me some help on this. Here's what I think is the relevant code from the plugin:
	// Runs when post is saved
	function save_video_thumbnail( $post ) {
		$post_type = get_post_type( $post->ID );
		if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) {
			return null;
		} else {
			// Check that Video Thumbnails are enabled for current post type
			if ( in_array( $post_type, (array) $this->settings->options['post_types'] ) || $post_type == $this->settings->options['post_types'] ) {
				get_video_thumbnail( $post->ID );
			} else {
				return null;
			}
		}
	}
July 15, 2013 at 5:06 am 5964
Tareq Hasan Tareq Hasan

I think that should do

[php]
function wpuf_get_vide_thumbnail( $post_id ) {
    get_video_thumbnail( $post_id );
}
 
add_action( ‘wpuf_add_post_after_insert’, ‘wpuf_get_vide_thumbnail’ );
add_action( ‘wpuf_edit_post_after_update’, ‘wpuf_get_vide_thumbnail’ );
[/php]

July 15, 2013 at 5:57 am 5966
djhaystack djhaystack

Worked perfectly. Thanks SO much.

Viewing 2 Posts - 1 through 2 (of 2 total)