• Resolved mammut3d

    (@mammut3d)


    Hi,
    First, thank you for you awesome plugin.
    I am using wordpress functions to automatically insert post in wordpress blog. I want to show the post in telegram channel after post insertion. Is there any function to insert post according admin settings just after my insertion? a function that gets post_id and send post to telegram channel after including your Wptelegram class?

    • This topic was modified 7 years, 5 months ago by mammut3d.
Viewing 6 replies - 1 through 6 (of 6 total)
  • Hello,
    If you use wp_insert_post function of WordPress, then the plugin will be triggered to handle the post data to be sent to Telegram. But, for this to work, you will have to uncheck “Show ON/OFF switch on the post edit screen” in WordPress Settings section of the plugin and then Save the Settings.

    Thread Starter mammut3d

    (@mammut3d)

    Yes, it works now. But there is a problem, i set the feature image after post insertion. Can you please give me another solution. I want to have feature image in telegram post. Or can you please tell me how to trig your plugin after set feature image. I have post id in that section.
    Thank you

    You can manually trigger the process by calling handle_save_post method of Wptelegram_Post_Handler class, by passing $post_id and $post as first and second argument respectively.
    But to only send featured image and to avoid the text being again, you can add this filter to make the message template empty.
    add_filter( 'wptelegram_message_template', '__return_false' );

    Another simple solution is to enable the option to send existing posts as well and use the above filter along with it when updating the post.

    Thread Starter mammut3d

    (@mammut3d)

    Thank you again.
    I think the first solution is nice, i searched about $post and because of my weakness in programing i did not understand concept of it.
    I have $post_id in program and how i can have $post?
    After that, Is this way correct?

    require_once('../wp-content/plugins/wptelegram/wptelegram.php');
    handle_save_post( $post_id, $post );
    • This reply was modified 7 years, 5 months ago by mammut3d.
    • This reply was modified 7 years, 5 months ago by mammut3d.

    If your code is executed by WordPress then you don’t need to include the plugin file. You can directly initialize the class.

    You can use get_post function to set $post variable. Like
    $post = get_post( $post_id );

    Thread Starter mammut3d

    (@mammut3d)

    Thank you for every thing. The problem is solved. I gave you 5 stars.

    • This reply was modified 7 years, 5 months ago by mammut3d.
Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Insert function’ is closed to new replies.