• Resolved S.Balachandran

    (@sbalachandran)


    Hi Jeff
    Your plugin is great and I have been using it for a while at my academic website: https://mbahub.in.
    While your documentation on Text Custom Fields works, in the sense the new text field gets saved in user meta and appears in profile, the same thing is not happening when applied to a dropdown select custom field (like course selected) in registration form. The profile page for the logged-in user does not show the selected option value, but the first option value of select dropdown in profile page. I shall be thankful, if you can point to any solution to this problem that you might have given in this forum – not sure if the problem has been raised before: difficult to go through all 130 pages. Thanks & regards.

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author Jeff Farthing

    (@jfarthing84)

    For dropdowns, you will need to check each option against the saved value to see which option should be selected.

    
    <?php
    $options = array(
        'course-1' => 'Course 1',
        'course-2' => 'Course 2',
        ...
    );
    ?>
    <select name="course">
        <?php foreach ( $options as $value => $label ) : ?>
            <option value="<?php echo esc_attr( $value ); ?>"<?php selected( $value, $user->course); ?>><?php echo esc_html( $label ); ?></option>
        <?php endforeach; ?>
    </select>
    
    Thread Starter S.Balachandran

    (@sbalachandran)

    Thanks for your quick response. I shall try this out asap & let you know the result.

    We were using the template override, and now with the 7.0 update, the custom form fields are missing. I am trying to follow the documentation, but how do I add the select type like the above to the “theme-my-login-custom.php” using the example in the documentation? (tml_add_form_field) thanks.

    Plugin Author Jeff Farthing

    (@jfarthing84)

    @kellykz You should probably start a new topic since this one was in regard to 6.4.x.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Dropdown Select Custom Fields in Registration’ is closed to new replies.