Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bporcelli/654cdb2828293c20def98849f7c039b1 to your computer and use it in GitHub Desktop.
Save bporcelli/654cdb2828293c20def98849f7c039b1 to your computer and use it in GitHub Desktop.
[MarketShip] Enable USPS flat rate services by default
<?php
/**
* Filters the default value of the marketship_shippo_usps_settings
* user meta key to enable flat rate services by default.
*
* @param mixed $value Meta value.
* @param int $user_id User ID.
* @param string $meta_key Meta key.
* @param bool $single Whether to return a single value.
*
* @return array|string
*/
function marketship_filter_default_usps_settings( $value, $user_id, $meta_key, $single ) {
if ( 'marketship_shippo_usps_settings' !== $meta_key ) {
return $value;
}
$default_settings = array(
'enable_flat_rate_services' => 'yes',
);
return $single ? $default_settings : array( $default_settings );
}
add_filter( 'default_user_metadata', 'marketship_filter_default_usps_settings', 10, 4 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment