Hooks.php
25 lines
| 1 | <?php |
| 2 | |
| 3 | namespace WCML\User; |
| 4 | |
| 5 | use IWPML_Frontend_Action; |
| 6 | use WPML\LIB\WP\Hooks as WpHooks; |
| 7 | use function WPML\FP\spreadArgs; |
| 8 | |
| 9 | class Hooks implements IWPML_Frontend_Action { |
| 10 | |
| 11 | public function add_hooks() { |
| 12 | WpHooks::onAction( 'woocommerce_created_customer', 10, 1 ) |
| 13 | ->then( spreadArgs( [ $this, 'setCustomerProfileLanguage' ] ) ); |
| 14 | } |
| 15 | |
| 16 | public function setCustomerProfileLanguage( $userId ) { |
| 17 | return wp_update_user( [ |
| 18 | 'ID' => $userId, |
| 19 | 'locale' => wpml_get_current_language(), |
| 20 | ] ); |
| 21 | } |
| 22 | |
| 23 | } |
| 24 | |
| 25 |