You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

29 lines
583 B

<?php
namespace WCML\User;
use IWPML_Frontend_Action;
use WPML\LIB\WP\Hooks as WpHooks;
use function WPML\FP\spreadArgs;
class Hooks implements IWPML_Frontend_Action {
public function add_hooks() {
WpHooks::onAction( 'woocommerce_created_customer', 10, 1 )
->then( spreadArgs( [ $this, 'setCustomerProfileLanguage' ] ) );
}
/**
* Set user's language to current language
*
* @param int $userId
*/
public function setCustomerProfileLanguage( $userId ) {
return wp_update_user( [
'ID' => $userId,
'locale' => wpml_get_current_language(),
] );
}
}