Home Forums Plugin Support WP User Frontend Pro Running Action Hook on Frontend Post

This topic is: resolved

This topic contains 2 replies, has 2 voices, and was last updated by  djhaystack 5 years, 8 months ago.

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #5961

    djhaystack
    Participant
    Post count: 2

    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;
    			}
    		}
    	}
    #5964

    Tareq Hasan
    Keymaster
    Post count: 2831

    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]

    #5966

    djhaystack
    Participant
    Post count: 2

    Worked perfectly. Thanks SO much.

Viewing 3 posts - 1 through 3 (of 3 total)

The topic ‘Running Action Hook on Frontend Post’ is closed to new replies.