beyondwords_content_params

Filters the body params we send to the BeyondWords API when processing audio.

beyondwords_body_params is deprecated and redirects to here. Please update to the new filter name; the functionality is exactly the same. The old filter will be removed in plugin version 5.0.

Parameters

$params array

The params we send to the BeyondWords API.


$post_idint

The WordPress post ID.


Example 1

Prepend the author name and the published date to the audio body.

function my_beyondwords_content_params( $params, $post_id ) {
    $name = get_the_author_meta( 'display_name', $post_id );
    $date = get_the_date( '', $post_id );

    $prepend = '';

    if ( $name ) {
        $prepend .= '<p>By ' . esc_html( $name ) . '</p>';
    }

    if ( $date ) {
        $prepend .= '<p>' . esc_html( $date ) . '</p>';
    }

    $params['body'] = $prepend . $params['body'];
    
    return $params;
}

add_filter( 'beyondwords_content_params', 'my_beyondwords_content_params', 10, 2 );

Example 2

Send the value of a custom field called "my_custom_field" to the BeyondWords API as a metadata field named "my_custom_key".

function my_beyondwords_content_params( $params, $post_id ) {
    if ( is_object( $params['metadata'] ) ) {
        $params['metadata']->my_custom_key = get_post_meta( $post_id, 'my_custom_field', true );
    }

    return $params;
}
add_filter( 'beyondwords_content_params', 'my_beyondwords_content_params', 10, 2 );

Example 3

Forward the value of a custom field to the BeyondWords API.

function my_beyondwords_content_params( $params, $post_id ) {
  // Use a custom field "my_ads_enabled" for the "ads_enabled" param for API requests
  $params[ 'ads_enabled' ] = (bool) get_post_meta( $post_id, 'my_ads_enabled', true );

  return $params;
}
add_filter( 'beyondwords_content_params', 'my_beyondwords_content_params', 10, 2 );

Changelog

VersionDescription

4.3.0

Deprecate beyondwords_body_params for beyondwords_content_params.

4.0.0

Introduced.

Last updated