> Faqs > Extra Field form register user
Esta Faq no ha sido aprovada por el equipo de moderadores de DesarrolloWeb.com por no seguir las normas de publicación de preguntas.

Extra Field form register user

hello I need a help. I have a New User Registration form and I am requesting to be able to add an extra field before the Name.

The developers of the plugin (unCanny) only provide me with a code that I must insert. They recommend that this action should be done by someone with php knowledge.

I pass them, here what they tell me:

Part 1:

Please download and replace them at the following paths:

  • users-table-actions.php = wp-content/plugins/uncanny-learndash-groups/src/templates/frontend-uo_groups/
  • rest-api-end-points.php = wp-content/plugins/uncanny-learndash-groups/src/classes/helpers/
  • class-group-management-helpers.php = wp-content/plugins/uncanny-learndash-groups/src/classes/group-management/

Once done, you can use the following actions to add and use additional fields.

// Before add and invite form fields do_action( 'ulgm_before_add_invite_form_fields', $group_id, $this );

// After add and invite form fields do_action( 'ulgm_after_add_invite_form_fields', $group_id, $this );

//The action runs after the user is invited to the group. $user_data has a user_id key that stores the new user ID do_action( 'ulgm_group_user_invited', $user_data, $group_id, $order_id );

This part, replace what they say.

NOW

Part 2:


/**

  • Add field */ add_action( 'ulgm_before_add_invite_form_fields', function ( $group_id, $_this ) { ?> <div class="uo-row"> <label for="my-custom-field"> <div class="uo-row__title"> Field label </div> </label> <input class="uo-input" required="required" type="text" name="my_custom_field" id="my-custom-field" value=""> </div> <?php }, 99, 2 );

/**

  • Save the value */ add_action( 'ulgm_group_user_invited', function ( $user_data, $group_id, $order_id ) { if ( ! isset( $user_data['user_id'] ) ) { return; } $user_id = absint( $user_data['user_id'] ); $my_custom_field = isset( $_POST['my_custom_field'] ) ? sanitize_text_field( $_POST['my_custom_field'] ) : ''; update_user_meta( $user_id, 'my_custom_field', $my_custom_field ); }, 99, 3

);

Here, here, I don't know, what to do? Can somebody help me?

Respuestas

Todavía no se han recibido respuestas a esta pregunta. ¿Quieres enviar la primera?