[Solved] Customise Jetpack Publicize text


Just some general remarks:

Why isn’t the following change working?

    $custom_message = get_the_title( $post->ID ) .''. $hash_tags;

to:

    $custom_message = get_the_content( $post->ID ) .' '. $hash_tags;

Note that get_the_content() doesn’t take a post ID as an input parameter and it depends on global variables, like $pages that’s derived from $post->post_content (with some pagination adjustments), within the WP_Query::setup_postdata() method.

This is how it’s defined:

function get_the_content( $more_link_text = null, $strip_teaser = false ) {
    global $page, $more, $preview, $pages, $multipage;
    ...
}

A starting point could be use

$post->post_content

if you have access to the $post object or

get_post_field( 'post_content', $post_ID );

if you only have the post ID and go from there.

Note that if you need to use the save_post hook, you can get the post ID and post object from the callback:

do_action( 'save_post', $post_ID, $post, $update );

so you don’t need to use get_post().

PS: I wonder if you can use this hook in JetPack (just skimmed through it):

do_action( 'publicize_save_meta', $submit_post, $post_id, $service_name, $connection );

but it seems to be fired for each services/connections.

2

solved Customise Jetpack Publicize text