WordPress.org

Ready to get started?Download WordPress

Forums

Theme My Login
TML errors/messages integration (1 post)

  1. piotr.tokarczyk
    Member
    Posted 1 year ago #

    Hello,
    i'm using register via fb/tw social plugin and i need to display error messages on login form page.
    I don't want to hack it.
    To do that your plugin need to be changed:

    function get_errors() {
    		global $theme_my_login, $error;
    
    		$wp_error =& $theme_my_login->errors;
    
    		if ( empty( $wp_error ) )
    			$wp_error = new WP_Error();
    
    		// Incase a plugin uses $error rather than the $errors object
    		if ( !empty( $error ) ) {
    			$wp_error->add('error', $error);
    			unset($error);
    		}
    
    		$output = '';
    		if ( $this->is_active ) {
    			if ( $wp_error->get_error_code() ) {
    				$errors = '';
    				$messages = '';
    				foreach ( $wp_error->get_error_codes() as $code ) {
    					$severity = $wp_error->get_error_data( $code );
    					foreach ( $wp_error->get_error_messages( $code ) as $error ) {
    						if ( 'message' == $severity )
    							$messages .= '    ' . $error . "<br />\n";
    						else
    							$errors .= '    ' . $error . "<br />\n";
    					}
    				}
    				if ( !empty( $errors ) )
    					$output .= '<p class="error">' . apply_filters( 'login_errors', $errors ) . "</p>\n";
    				if ( !empty( $messages ) )
    					$output .= '<p class="message">' . apply_filters( 'login_messages', $messages ) . "</p>\n";
    			}
    		}
    		return $output;
    	}

    to something like this:

    function get_errors() {
    		global $theme_my_login, $error;
    
    		$wp_error =& $theme_my_login->errors;
    
    		if ( empty( $wp_error ) )
    			$wp_error = new WP_Error();
    
    		// Incase a plugin uses $error rather than the $errors object
    		if ( !empty( $error ) ) {
    			$wp_error->add('error', $error);
    			unset($error);
    		}
    
    		$output = '';
                    $errors = apply_filters( 'login_errors', '');
                    $messages = apply_filters( 'login_messages', '');
    		if ( $this->is_active ) {
    			if ( $wp_error->get_error_code() ) {
    				$errors = '';
    				$messages = '';
    				foreach ( $wp_error->get_error_codes() as $code ) {
    					$severity = $wp_error->get_error_data( $code );
    					foreach ( $wp_error->get_error_messages( $code ) as $error ) {
    						if ( 'message' == $severity )
    							$messages .= '    ' . $error . "<br />\n";
    						else
    							$errors .= '    ' . $error . "<br />\n";
    					}
    				}
    				if ( !empty( $errors ) )
    					$output .= '<p class="error">' . $errors . "</p>\n";
    				if ( !empty( $messages ) )
    					$output .= '<p class="message">' . $messages . "</p>\n";
    			}
    		}
    		return $output;
    	}

    Now if TML errors will be empty error message will not be displayed no matter if I call add_filter.

    http://wordpress.org/extend/plugins/theme-my-login/

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

  • RSS feed for this topic
  • Started 1 year ago by piotr.tokarczyk
  • This topic is not resolved
  • WordPress version: 3.5.1