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.
35 lines
1.4 KiB
35 lines
1.4 KiB
<?php
|
|
|
|
// Сохранить значения полей
|
|
add_action('wp_ajax_edit_user', 'save_custom_user_profile_fields');
|
|
add_action('wp_ajax_nopriv_edit_user', 'save_custom_user_profile_fields'); //
|
|
|
|
function save_custom_user_profile_fields() {
|
|
// Проверка прав пользователя
|
|
wp_update_user( array(
|
|
'ID' => get_current_user_id(),
|
|
'first_name' => $_POST['name'],
|
|
'last_name' => $_POST['l_name'],
|
|
|
|
) );
|
|
|
|
$phone = update_user_meta( get_current_user_id(), 'billing_phone', $_POST['full'] );
|
|
|
|
}
|
|
|
|
pll_register_string( 'Link email', 'Link email');
|
|
pll_register_string( 'Linked accounts', 'Linked accounts');
|
|
|
|
|
|
add_action('template_redirect', 'redirect_non_logged_in_users');
|
|
|
|
function redirect_non_logged_in_users() {
|
|
// URL личного кабинета (замените 'your-account-page-slug' на ваш slug)
|
|
$account_page_slug = 'my-account-3';
|
|
$account_page_slug__2 = 'my-account';
|
|
// Проверяем, находится ли пользователь на странице личного кабинета
|
|
if (is_page($account_page_slug) && !is_user_logged_in() || is_page($account_page_slug__2) && !is_user_logged_in() ) {
|
|
wp_redirect(home_url()); // Перенаправляем на главную страницу
|
|
exit;
|
|
}
|
|
} |