I'm very new to WordPress so I have a simple beginner question.
I've added some custom user fields on the admin form with the action show_user_profile
, edit_user_profile
, personal_options_update
, and edit_user_profile_update
. Everything works very well.
Now I want to give my users the possibility to update their profiles via the frontend. So I created a simple HTML form:
<form method="POST" action="">
<div class="form-group">
<label for="firstname">Name</label>
<input type="text"
name="firstname"
id="firstname"
value="<?= esc_attr(wp_get_current_user()->user_firstname) ?>"
placeholder="Vorname">
</div>
<div class="form-group">
<label for="name">Name</label>
<input type="text"
name="name"
id="name"
value="<?= esc_attr(wp_get_current_user()->user_lastname) ?>"
placeholder="Name">
</div>
<div class="form-group">
<label for="username">Benutzername</label>
<input type="text"
name="username"
id="username"
value="<?= esc_attr(wp_get_current_user()->user_login) ?>"
placeholder="Benutzername">
</div>
<div class="form-group">
<label for="street">Straße</label>
<input type="text"
name="street"
id="street"
value="<?= esc_attr(get_user_meta(get_current_user_id(), 'street', true)) ?>"
placeholder="Straße">
</div>
<div class="form-group">
<div class="row">
<div class="col-md-4">
<label for="zip">PLZ</label>
<input type="text"
name="zip"
id="zip"
value="<?= esc_attr(get_user_meta(get_current_user_id(), 'zipcode', true)) ?>"
placeholder="PLZ"
maxlength="5">
</div>
<div class="col-md-8">
<label for="location">Ort</label>
<input type="text"
name="location"
id="location"
value="<?= esc_attr(get_user_meta(get_current_user_id(), 'city', true)) ?>"
placeholder="Ort">
</div>
</div>
</div>
<div class="form-group">
<label for="street">Telefonnummer</label>
<input type="text"
name="phone"
id="phone"
placeholder="Telefonnummer"
value="<?= esc_attr(get_user_meta(get_current_user_id(), 'phone', true)) ?>">
</div>
<div class="form-group">
<label for="street">E-Mail-Adresse</label>
<input type="email"
name="email"
id="email"
value="<?= esc_attr(wp_get_current_user()->user_email) ?>"
placeholder="E-Mail-Adresse">
</div>
<button type="submit" class="btn-mitmachen btn-small">Speichern</button>
</form>
My question is which action do I call with the form to update current logged in users? Is there something like a hook or do I write the logic for the profile by myself?