beyondwords_player_sdk_params

Filters the BeyondWords Player SDK parameters.

This filter is only applied to the Latest player version. If you are using the Legacy player then please update to Latest player. The Legacy player will deprecated soon in plugin version 5.0.

Refer to the Player Settings for a the list of available parameters.

Parameters

$params array

The SDK parameters.


$post_idint

The post ID.


Example 1

Use a custom colour for the text in all players.

function my_beyondwords_player_sdk_params( $params, $post_id ) {
  $params[ 'textColor' ] = 'rgba(255, 0, 0, 0.8)';

  return $params;
}
add_filter( 'beyondwords_player_sdk_params', 'my_beyondwords_player_sdk_params', 10, 2 );

Example 2

Set the Advert consent parameter for all users.

function my_beyondwords_player_sdk_params( $params, $post_id ) {
  $params[ 'advertConsent' ] = 'non-personalized';

  return $params;
}
add_filter( 'beyondwords_player_sdk_params', 'my_beyondwords_player_sdk_params', 10, 2 );// Some code

Example 3

Use a blue icon colour for players in posts tagged with "News".

function my_beyondwords_player_sdk_params( $params, $post_id ) {
  $tags = get_the_tags( $post_id );

  foreach ( $tags as $tag ) {
    if ( isset( $tag->name ) && $tag->name === "News" ) {
      $params[ 'iconColor' ] = '#000080'; // Navy blue
    }
  } 

  return $params;
}
add_filter( 'beyondwords_player_sdk_params', 'my_beyondwords_player_sdk_params', 10, 2 );

Example 4

Skip ads for signed-in users.

function my_beyondwords_player_sdk_params( $params, $post_id ) {
  $current_user = wp_get_current_user(); 

  if ( $current_user->exists() ) {
    // This will override the project defaults
    $params['adverts'] = []; 
  } 

  return $params;
}
add_filter( 'beyondwords_player_sdk_params', 'my_beyondwords_player_sdk_params', 10, 2 );

Changelog

Last updated