• Resolved josefrances29

    (@josefrances29)


    Hi,

    I have created a demo sensei website for my client and I added a registration form with extra custom fields called the first_name and the last_name to be added in the user credentials which is working fine but when I added this plugin Better Notification and I tested it sending the form to my personal email address, the problem is the shortcode [email_user_firstname], and [email_user_lastname] doesn’t show on my email body except for the other shortcodes. Here’s a sample screenshot for the result https://snipboard.io/F3BHaI.jpg and here’s the sample screenshot for my registration fields https://snipboard.io/XhPp0b.jpg. I really need to generate the first name of all sensei subscriber so that I can send them a formal email notification mentioning their names. I really appreciate any help form this forum.

    Kind Regards,
    Francees

    The page I need help with: [log in to see the link]

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Author Jack – BNFW

    (@voltronik)

    Hi @josefrances29,
    Thanks for your message.

    This usually happens when the additional custom fields are saved after the notification has been sent. You’ll need to change the hook you’re using to save the additional data to something sooner in order to ensure everything is available when the notification is sent.

    Hope this helps.

    Thread Starter josefrances29

    (@josefrances29)

    Hey @bnfw,

    Anyway, a blessed new year to you, and thank you for your reply.

    Could you please take a look at my code below which is added in the functions.php

    This is what my code looks like and could you please clarify if all I need is to change the function of this script. Thank you. 🙂

    add_action( ‘register_form’, ‘myplugin_register_form’ );
    function myplugin_register_form() {

    $first_name = ( ! empty( $_POST[‘first_name’] ) ) ? trim( $_POST[‘first_name’] ) : ”;
    $last_name = ( ! empty( $_POST[‘last_name’] ) ) ? trim( $_POST[‘last_name’] ) : ”;

    ?>
    <p>
    <label for=”first_name”><?php _e( ‘First Name’, ‘mydomain’ ) ?><br />
    <input type=”text” name=”first_name” id=”first_name” class=”input” value=”<?php echo esc_attr( wp_unslash( $first_name ) ); ?>” size=”25″ /></label>
    </p>

    <p>
    <label for=”last_name”><?php _e( ‘Last Name’, ‘mydomain’ ) ?><br />
    <input type=”text” name=”last_name” id=”last_name” class=”input” value=”<?php echo esc_attr( wp_unslash( $last_name ) ); ?>” size=”25″ /></label>
    </p>

    <?php
    }

    //2. Add validation. In this case, we make sure first_name is required.
    add_filter( ‘registration_errors’, ‘myplugin_registration_errors’, 10, 3 );
    function myplugin_registration_errors( $errors, $sanitized_user_login, $user_email ) {

    if ( empty( $_POST[‘first_name’] ) || ! empty( $_POST[‘first_name’] ) && trim( $_POST[‘first_name’] ) == ” ) {
    $errors->add( ‘first_name_error’, __( ‘ERROR: You must include a first name.’, ‘mydomain’ ) );
    }
    if ( empty( $_POST[‘last_name’] ) || ! empty( $_POST[‘last_name’] ) && trim( $_POST[‘first_name’] ) == ” ) {
    $errors->add( ‘last_name_error’, __( ‘ERROR: You must include a first name.’, ‘mydomain’ ) );
    }
    return $errors;
    }

    //3. Finally, save our extra registration user meta.
    add_action( ‘user_register’, ‘myplugin_user_register’ );
    function myplugin_user_register( $user_id ) {
    if ( ! empty( $_POST[‘first_name’] ) ) {
    update_user_meta( $user_id, ‘first_name’, trim( $_POST[‘first_name’] ) );
    update_user_meta( $user_id, ‘last_name’, trim( $_POST[‘last_name’] ) );
    }
    }

    Plugin Author Jack – BNFW

    (@voltronik)

    Hi @josefrances29,
    I honestly couldn’t say out of context but I’d advise testing it and seeing how you get on.

    Thread Starter josefrances29

    (@josefrances29)

    @voltronik Thanks for your help and I will try to see how will I be able to set and save the extra fields before it sends the notification to my email.

    I am getting the same issue for the New Registration and I am getting the only shortcode in the mail and below is the screenshot.

    2021-02-26_20-50-03

    Plugin Author Jack – BNFW

    (@voltronik)

    @vikramrout Please can you start a new thread for this in case your issue is different.

Viewing 6 replies - 1 through 6 (of 6 total)

The topic ‘First name and last name doesn’t show after submitting my registration form’ is closed to new replies.