Привет, я создал код функции формы внутри функции темы.function custom_counsellor_registration_form() {
ob_start();
$form_action = esc_url(trailingslashit(get_permalink()));
error_log('Counsellor Form Action URL: ' . $form_action);
if (isset($_POST['counsellor_registration_submit'])) {
error_log('Counsellor Form Submitted. POST Data: ' . print_r($_POST, true));
$name = sanitize_text_field($_POST['name']);
$designation = sanitize_text_field($_POST['designation']);
$qualification = sanitize_text_field($_POST['qualification']);
$time_slots = isset($_POST['time_slots']) ? array_map('sanitize_text_field', $_POST['time_slots']) : array();
$specification = sanitize_textarea_field($_POST['specification']);
$username = sanitize_text_field($_POST['username']);
$email = sanitize_email($_POST['email']);
$password = $_POST['password'];
$agreement = isset($_POST['agreement']) ? 1 : 0;
$errors = [];
if (empty($username) || empty($email) || empty($password)) {
$errors[] = "Username, email, and password are required.";
}
if (!is_email($email)) {
$errors[] = "Please enter a valid email address.";
}
if (strlen($password) < 6) {
$errors[] = "Password must be at least 6 characters long.";
}
if (empty($errors) && $agreement) {
$user_id = wp_create_user($username, $password, $email);
if (!is_wp_error($user_id)) {
wp_update_user(array('ID' => $user_id, 'role' => 'counsellor'));
update_user_meta($user_id, 'name', $name);
update_user_meta($user_id, 'designation', $designation);
update_user_meta($user_id, 'qualification', $qualification);
update_user_meta($user_id, 'time_slots', $time_slots);
update_user_meta($user_id, 'specification', $specification);
wp_redirect(wp_login_url() . '?registration=success');
exit;
} else {
error_log('Counsellor Registration Error: ' . $user_id->get_error_message());
$errors[] = $user_id->get_error_message();
}
}
if (!empty($errors)) {
echo '';
foreach ($errors as $error) {
echo '
' . esc_html($error) . '
';
}
echo '';
} else if (!$agreement) {
echo '
Please agree to the terms to proceed.
';
}
}
?>
Counsellor Registration
Name:
Подробнее здесь: https://stackoverflow.com/questions/795 ... -wordpress
После подачи формы 404 ошибка в WordPress ⇐ Php
Кемеровские программисты php общаются здесь
1745605897
Anonymous
Привет, я создал код функции формы внутри функции темы.function custom_counsellor_registration_form() {
ob_start();
$form_action = esc_url(trailingslashit(get_permalink()));
error_log('Counsellor Form Action URL: ' . $form_action);
if (isset($_POST['counsellor_registration_submit'])) {
error_log('Counsellor Form Submitted. POST Data: ' . print_r($_POST, true));
$name = sanitize_text_field($_POST['name']);
$designation = sanitize_text_field($_POST['designation']);
$qualification = sanitize_text_field($_POST['qualification']);
$time_slots = isset($_POST['time_slots']) ? array_map('sanitize_text_field', $_POST['time_slots']) : array();
$specification = sanitize_textarea_field($_POST['specification']);
$username = sanitize_text_field($_POST['username']);
$email = sanitize_email($_POST['email']);
$password = $_POST['password'];
$agreement = isset($_POST['agreement']) ? 1 : 0;
$errors = [];
if (empty($username) || empty($email) || empty($password)) {
$errors[] = "Username, email, and password are required.";
}
if (!is_email($email)) {
$errors[] = "Please enter a valid email address.";
}
if (strlen($password) < 6) {
$errors[] = "Password must be at least 6 characters long.";
}
if (empty($errors) && $agreement) {
$user_id = wp_create_user($username, $password, $email);
if (!is_wp_error($user_id)) {
wp_update_user(array('ID' => $user_id, 'role' => 'counsellor'));
update_user_meta($user_id, 'name', $name);
update_user_meta($user_id, 'designation', $designation);
update_user_meta($user_id, 'qualification', $qualification);
update_user_meta($user_id, 'time_slots', $time_slots);
update_user_meta($user_id, 'specification', $specification);
wp_redirect(wp_login_url() . '?registration=success');
exit;
} else {
error_log('Counsellor Registration Error: ' . $user_id->get_error_message());
$errors[] = $user_id->get_error_message();
}
}
if (!empty($errors)) {
echo '';
foreach ($errors as $error) {
echo '
' . esc_html($error) . '
';
}
echo '';
} else if (!$agreement) {
echo '
Please agree to the terms to proceed.
';
}
}
?>
Counsellor Registration
Name:
Подробнее здесь: [url]https://stackoverflow.com/questions/79593134/after-form-submission-404-error-coming-in-wordpress[/url]
Ответить
1 сообщение
• Страница 1 из 1
Перейти
- Кемерово-IT
- ↳ Javascript
- ↳ C#
- ↳ JAVA
- ↳ Elasticsearch aggregation
- ↳ Python
- ↳ Php
- ↳ Android
- ↳ Html
- ↳ Jquery
- ↳ C++
- ↳ IOS
- ↳ CSS
- ↳ Excel
- ↳ Linux
- ↳ Apache
- ↳ MySql
- Детский мир
- Для души
- ↳ Музыкальные инструменты даром
- ↳ Печатная продукция даром
- Внешняя красота и здоровье
- ↳ Одежда и обувь для взрослых даром
- ↳ Товары для здоровья
- ↳ Физкультура и спорт
- Техника - даром!
- ↳ Автомобилистам
- ↳ Компьютерная техника
- ↳ Плиты: газовые и электрические
- ↳ Холодильники
- ↳ Стиральные машины
- ↳ Телевизоры
- ↳ Телефоны, смартфоны, плашеты
- ↳ Швейные машинки
- ↳ Прочая электроника и техника
- ↳ Фототехника
- Ремонт и интерьер
- ↳ Стройматериалы, инструмент
- ↳ Мебель и предметы интерьера даром
- ↳ Cантехника
- Другие темы
- ↳ Разное даром
- ↳ Давай меняться!
- ↳ Отдам\возьму за копеечку
- ↳ Работа и подработка в Кемерове
- ↳ Давай с тобой поговорим...
Мобильная версия