WordPress.org

Ready to get started?Download WordPress

Forums

Front-End Users
feu_get_display_names_options_html($user) (2 posts)

  1. Dominor Novus
    Member
    Posted 2 years ago #

    In the default WordPress profile, the display name is selected from a <select> menu that's dynamically generated based on the inputted nickname.

    This doesn't seem to happen with FEU. I have to submit the form for the nickname to populate the display name.

    Right now, I'm researching a little javascript or else how to force the display name to take the nickname value so I can bypass the select field altogether.

    Related question here:
    http://wordpress.stackexchange.com/questions/35403/forcing-nickname-as-display-name-in-custom-edit-profile-template

    http://wordpress.org/extend/plugins/front-end-users/

  2. Dominor Novus
    Member
    Posted 2 years ago #

    I've figured out how to "force" the nickname as the display_name.

    I mimicked WordPress's default "edit profile" page using a little jQuery. Whatever value is input into the nickname field will automatically be inputted into display_name text box. I replaced the select box with a text box since the value will always be the inputted nickname.

    Just copy and paste the following into your custom template page:

    <?php
    
    global $feu;
    
    $user = wp_get_current_user();
    $update_status = null;
    $user_avatar_enabled = $feu->is_user_avatar_enabled();
    
    if (!empty($_POST)) {
    	$update_status = $feu->update_user_settings($user, $_POST);
    }
    
    if ($user_avatar_enabled) {
    	$feu->enqueue_user_avatar_resources();
    }
    
    feu_header();
    
    ?>
    
    <?php feu_box_(); ?>
    
    	<?php feu_form_message($update_status); ?>
    
    	<div class="feu-form">
    
    		<?php
    			if ($user_avatar_enabled) {
    				user_avatar_form($user);
    			}
    		?>
    
    		<form action="<?php echo feu_get_url('settings'); ?>" method="post" id="custom_DS_feu_profile_settings">
    
    <h3>Name</h3>
    
                                    <div>
    
    					<label>Username (cannot be edited)</label>
    
    					<div>
                                                    <input type="text" value="<?php echo $user->user_login; ?>" readonly="readonly"/>
    
    					</div>
    
    				</div>
    
    				<div>
    
    					<label for="first_name">First Name</label>
    
    					<div>
    						<input type="text" name="first_name" value="<?php echo esc_attr($user->first_name); ?>" />
    					</div>
    
    				</div>
    
    				<div>
    
    					<label for="last_name">Last Name</label>
    
    					<div>
    						<input type="text" name="last_name" value="<?php echo esc_attr($user->last_name); ?>" />
    					</div>
    
    				</div>
    
    				<div>
    
    					<label for="nickname">Nickname <span>(required)</span></label>
    
    					<div>
    						<input type="text" name="nickname" value="<?php echo esc_attr($user->nickname); ?>" id="nickname" />
    					</div>
    
    				</div>
    
    				<div>
    
    					<label for="display_name">Display Name</label>
    
    <!-------------------------------------------------------------------------------------------------------------------
    					<div>
    						<select name="display_name">
    							<?php echo feu_get_display_names_options_html($user); ?>
    						</select>
    					</div>
    --------------------------------------------------------------------------------------------------------------------->
    
    					<div>
    						<input type="text" name="display_name" value="<?php echo esc_attr($user->display_name); ?>" id="display_name" readonly="readonly"/>
    					</div>
    
    <script type="text/javascript">
    jQuery.noConflict();
    
    jQuery(function() {
       var myInput = jQuery('#nickname');
       myInput.change(function() {
           jQuery('#display_name').val(myInput.val());
       });
    });
    </script>
    
    				</div>
    
    				<h3>Contact Info</h3>
    
    				<div>
    
    					<label for="email">Email</label>
    
    					<div>
    						<input type="text" name="email" value="<?php echo esc_attr($user->user_email); ?>" />
    					</div>
    
    				</div>
    
    				<h3>Password</h3>
    
    				<div>
    
    					<label for="pass1">New Password</label>
    
    					<div>
    						<input type="password" name="pass1" value="" autocomplete="off" /> <span class="description">If you would like to change the password type a new one. Otherwise leave this blank.</span><br />
    						<input type="password" name="pass2" value="" autocomplete="off" /> <span class="description">Type your new password again.</span>
    					</div>
    
    				</div>
    
    			<?php if ($feu->get_display_custom_profile_settings()): ?>
    
    				<?php do_action( 'show_user_profile', $user ); ?>
    
    			<?php endif; ?>
    
    			<div class="submit">
    
    				<input type="hidden" name="user_id" value="<?php echo esc_attr($user->ID); ?>" />
    				<input type="submit" name="submit" value="Update" />
    
    			</div>
    
    		</form>
    
    	</div>
    
    <?php _feu_box(); ?>
    
    <?php feu_footer(); ?>

    Any feedback from the author would be appreciated. I'm guessing I should be using a filter.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic