-
Notifications
You must be signed in to change notification settings - Fork 0
User Meta
rogertm edited this page Oct 17, 2023
·
8 revisions
Podemos agregar custom fields a la página de edición de cada usuario creando una nueva clase hija de WASP\Users\User_Meta.
<?php
use WASP\Users\User_Meta;
class My_Plugin_User_Meta extends User_Meta
{
function fields()
{
$fields = array(
'field_name' => array(
'label' => __( 'Title', 'text-domain' ),
'meta' => 'field_name'
),
/** more fields here */
);
return $fields;
}
}
new My_Plugin_User_Meta;Los campos personalizados definidos en el método fields() aparecerán en la pantalla de creación y edición de cada usuario.
Para recuperar el valor de cada campo se debe usar la función get_user_meta().
get_user_meta( $user_id, 'field_name', true );- Hook
show_user_profile. - Hook
edit_user_profile. - Hook
user_new_form. - Hook
personal_options_update. - Hook
edit_user_profile_update. - Hook
user_register. - Function
get_user_meta().