• On the blog i’m working on, i wanted to make the login/register links in a staight line. I moved the
    <?php wp_loginout(); ?> and it showed exactly as i wanted it. Then i got to <?php wp_register(); ?> and it had a huge
    <li> dot before it and it was on a line underneath the login link.

    How can i fix this?

Viewing 2 replies - 1 through 2 (of 2 total)
  • You can’t just “fix” it. wp_register contains the
    <li> bit you are referring to. I couldn’t actually find the function to modify it so I wrote my own. This should do it for you. I had to create a custom one to insert a <span> section right around the text.

    function custom_regadmin() {
    	global $user_ID;
    	get_currentuserinfo();
    
    	if ('' == $user_ID) :
    	   $link = '<a href="' . get_option('siteurl') . '/wp-register.php">' . __('Register') . '</a>';
    	else :
    	   $link = '<a href="' . get_option('siteurl') . '/wp-admin">' . __('Site Admin') . '</a>';
          endif;
    	echo apply_filters('regadmin', $link);
    }

    Call custom_regadmin() instead of wp_register() to use this one. If you need a place to put the code then put it in your theme’s function.php file. It will work fine from there. ??

    Not sure how these relate but here’s where registration and login code is located.

    These 2 functions are located at wp-includes/general-template.php

    function wp_loginout()
    	if ( ! is_user_logged_in() )
    		$link = '<a href="' . site_url('wp-login.php', 'login') . '">' . __('Log in') . '</a>';
    	else
    		$link = '<a href="' . site_url('wp-login.php?action=logout', 'login') . '">' . __('Log out') . '</a>';
    
    	echo apply_filters('loginout', $link);
    }
    
    function wp_register( $before = '
    <li>', $after = '</li>
    ' ) {
    
    	if ( ! is_user_logged_in() ) {
    		if ( get_option('users_can_register') )
    			$link = $before . '<a href="' . site_url('wp-login.php?action=register', 'login') . '">' . __('Register') . '</a>' . $after;
    		else
    			$link = '';
    	} else {
    		$link = $before . '<a href="' . admin_url() . '">' . __('Site Admin') . '</a>' . $after;
    	}

    and this one is located in /wp-login.php

    /**
     * register_new_user() - Handles registering a new user
     *
     * {@internal Missing Long Description}}
     *
     * @param string $user_login User's username for logging in
     * @param string $user_email User's email address to send password and add
     * @return int|WP_Error Either user's ID or error on failure.
     */
    function register_new_user($user_login, $user_email) {
    	$errors = new WP_Error();
    
    	$user_login = sanitize_user( $user_login );
    	$user_email = apply_filters( 'user_registration_email', $user_email );
    
    	// Check the username
    	if ( $user_login == '' )
    		$errors->add('empty_username', __('<strong>ERROR</strong>: Please enter a username.'));
    	elseif ( !validate_username( $user_login ) ) {
    		$errors->add('invalid_username', __('<strong>ERROR</strong>: This username is invalid.  Please enter a valid username.'));
    		$user_login = '';
    	} elseif ( username_exists( $user_login ) )
    		$errors->add('username_exists', __('<strong>ERROR</strong>: This username is already registered, please choose another one.'));
    
    	// Check the e-mail address
    	if ($user_email == '') {
    		$errors->add('empty_email', __('<strong>ERROR</strong>: Please type your e-mail address.'));
    	} elseif ( !is_email( $user_email ) ) {
    		$errors->add('invalid_email', __('<strong>ERROR</strong>: The email address isn’t correct.'));
    		$user_email = '';
    	} elseif ( email_exists( $user_email ) )
    		$errors->add('email_exists', __('<strong>ERROR</strong>: This email is already registered, please choose another one.'));
    
    	do_action('register_post', $user_login, $user_email, $errors);
    
    	$errors = apply_filters( 'registration_errors', $errors );
    
    	if ( $errors->get_error_code() )
    		return $errors;
    
    	$user_pass = wp_generate_password();
    	$user_id = wp_create_user( $user_login, $user_pass, $user_email );
    	if ( !$user_id ) {
    		$errors->add('registerfail', sprintf(__('<strong>ERROR</strong>: Couldn’t register you... please contact the <a href="mailto:%s">webmaster</a> !'), get_option('admin_email')));
    		return $errors;
    	}
    
    	wp_new_user_notification($user_id, $user_pass);
    
    	return $user_id;
    }

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘wp_register(); Problem’ is closed to new replies.