Design · PHP · Server

Design · PHP · Server

WordPress · Drupal · PrestaShop

  • Startseite
  • WordPress
  • PHP
  • Ubuntu
  • Prestashop
  • Indesign
  • Grafik
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 Antworten abbrechen

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

Themen

Adminbar Apache Attachment Count Automatische Updates Backend Boolean values Boolesche Werte BuddyPress Code Snippets Concatenation Operator Conditional Statement Datenbank Email Enfold Escape Zeichen Galerien genesis Grid View htaccess Layout Builder List View Logische Operatoren Loops Maskieren Media Manager Mitgliederbereich PHP PHP Anfänger PHP Variablen Plugins Prestashop Prestashop 1.5 Prestashop 1.6 Prestashop Module Registrierung RSS Feed s2member Server ssl Strings Windows Windows 10 WooCommerce WooCommerce Sortierung WordPress

Letzte Kommentare

  • Thomas bei WordPress: Einzelne Kategorien aus dem RSS Feed ausschließen
  • Bernhard bei CSS: Automatische Silbentrennung in einzelnen Wörtern verhindern
  • Bernhard bei CSS: Automatische Silbentrennung in einzelnen Wörtern verhindern
  • MC bei PHP: Boolesche Werte (Boolean Values)
  • eno bei Zufällige Produktanordnung beim Featured Product Slider (PrestaShop 6.1.11 / Megashop Theme)

Informationen

  • Kontakt
  • Datenschutzerklärung
  • Impressum
  • Kontakt
  • Datenschutzerklärung
  • Impressum