• Resolved emliron

    (@emliron)


    Hello,

    I’d like to use the deepl_translate_post_link function in the wp_insert_post hook (in functions.php). How do I declare this plugin function?

    Thanks for your help

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author malaiac

    (@malaiac)

    Would you like the post insertion to launch a translation, or would you like a translation to insert a post ? ??

    Thread Starter emliron

    (@emliron)

    Thank you for your reply.
    Our site https://www.assopogo.net is bilingual French/English (WPML).
    I use Buddypress for the forums.
    I would like a message written in English to be translated into French and vice versa.
    For the moment, it’s simply duplicated in the other language. Using the wp_insert_post hook, I can modify the content with wp_update_post.
    I just need to translate the content, and the title, before applying wp_update_post.
    I’d like to use a plugin function for this.

    I hope I’ve made myself clear!
    Sincerely
    Emmanuel Liron

    Plugin Author malaiac

    (@malaiac)

    C’est clair ??

    You’ll need to add something like this somewhere :

    add_action('wp_insert_post', 'mysite_translate_post', 10, 3);
    function mysite_translate_post( $new_post_id, $WP_Post, $update) { 
    	if( $update ) return;
    	$args = array(
    		'ID'	=> $new_post_id,
    		'target_lang'	=> 'en_GB',
    	);
    	$updated = deepl_translate_post_link( $args );
    }
    • This reply was modified 1 year, 4 months ago by malaiac.
    Thread Starter emliron

    (@emliron)

    Thank you.
    That’s pretty much what I wrote. But I got an error message: Call to undefined function deepl_translate_post_link()

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘deepl_translate_post_link’ is closed to new replies.