Design Meets Code

Design Meets Code

WordPress · PrestaShop

  • Startseite
  • WordPress
  • PHP / Datenbanken
  • Ubuntu
  • Prestashop
  • Grafik
  • Glossar
You are here: Home / WordPress / Zusätzliche Felder bei der WordPress Registrierung

Zusätzliche Felder bei der WordPress Registrierung

24. Juni 2017 Leave a Comment

Drei Hooks kommen zur Anwendung:

add_action('register_form','show_country_field');
add_action('register_post','check_country_field',10,3);
add_action('user_register', 'register_country_field');

Die Funktionen

function wle_show_country_field() {
$user_country = ( isset( $_POST['user_country'] ) ) ? $_POST['user_country']: '';
$country_picker = wle_get_country_list();
?>
<p>
<label>Country<br/>
<select name="user_country">
<option value=""></option>
<?php foreach ($country_picker as $country) {
if ($user_country == $country) {
$selected = 'selected'; }
else {
$selected = '';
}
echo '<option value="' . $country . '" ' . $selected . '>' . $country . '</option>';
} ?>
</select>
</label>
</p>
<?php
}
function wle_check_country_field($sanitized_user_login, $user_email, $errors) {
	if (empty($_POST['user_country'])) {
		$errors->add( 'user_country_error', __('ERROR: You must choose a country.','mydomain') );
	}
	return $errors;
}
function register_country_field($user_id) {
	if (isset($_POST['user_country'])) {
		update_user_meta($user_id, 'user_country', $_POST['user_country']);
	}
}

Quelle: http://www.setupmyvps.com/how-to-add-a-custom-field-to-wordpress-registration/ | WordPress Codex

Filed Under: WordPress Tagged With: Custom Fields, Registrierung

Schreibe einen Kommentar Antwort abbrechen

Deine E-Mail-Adresse wird nicht veröffentlicht. Erforderliche Felder sind mit * markiert

Anzeige

Themen

Apache BuddyPress Code Snippets Datenbank Email Enfold genesis Grid View htaccess imscp Indesign Katalogpreisregel Layout Builder LibreOffice Lieferschein List View Logout Mitgliederbereich MySQL PHP PHP Anfänger PHP Variablen Plugins Prestashop Prestashop 1.5 Prestashop 1.6 Prestashop 1.7 Prestashop 8 Prestashop Module Registrierung RSS Feed s2member Screencast Server Sicherheit ssl Startseite Strings Tipps Windows Windows 10 Windows 11 WooCommerce WooCommerce Sortierung WordPress
Anzeige

Letzte Kommentare

  • Martin bei CSS: Automatische Silbentrennung in einzelnen Wörtern verhindern
  • Martin bei CSS: Automatische Silbentrennung in einzelnen Wörtern verhindern
  • Klaus bei Woocommerce: Shop Seiten neu generieren
  • Thomas bei WordPress: Einzelne Kategorien aus dem RSS Feed ausschließen
  • Bernhard bei CSS: Automatische Silbentrennung in einzelnen Wörtern verhindern

Informationen

  • Kontakt
  • Datenschutzerklärung
  • Impressum
  • Cookie-Richtlinie (EU)
  • Kontakt
  • Datenschutzerklärung
  • Impressum
  • Cookie-Richtlinie (EU)
Anzeige