WordPress.org

Support

Support » Plugins and Hacks » Theme My Login » [Resolved] [PATCH] qTranslate support for forms that are redirected after submission

[Resolved] [PATCH] qTranslate support for forms that are redirected after submission

  • Daedalon

    @daedalon

    Updating the profile by submitting the form leads the user to the profile page in the default language, regardless of what language they had chosen.

    For fix, locate in modules/themed-profiles/themed-profiles.php the line 167:

    $redirect = add_query_arg( array( 'updated' => 'true' ) );

    and add these right after it:

    // Support qTranslate's language-aware URLs
    				if ( function_exists( 'qtrans_convertURL' ) ) {
    					$redirect = qtrans_convertURL( $redirect );
    					// Needed to convert & to &, raises a 403 error without
    					$redirect = htmlspecialchars_decode( $redirect );
    				}

    Haven’t yet encountered the following need, but it might be that the same should be applied after line 28:

    $redirect_to = $theme_my_login->get_login_page_link( array( 'action' => 'profile' ) );

    The same should also be applied to at least registration, login and forgot password forms in order to let the user see the error messages in his/her chosen language.

    For supporting other plugins like WPML, it’s possible to move these all behind an abstraction. Make an abstraction file with a function “tml_multilingual_url” and have it recognize whether it should call a different file with a function “tml_qtranslate_url” or “tml_wpml_url”, and call the functions in the abstraction file instead of the current straight-out patch.

    That abstraction fixes the only drawback I can perceive in the patch submitted above, which is the maintainability of the code.

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

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

    @jfarthing84

    Not going to happen. I am not adding another developers functions to my plugin. This is why I have added actions and filters just about everywhere that they are useful.

    Nitroweb

    @spyrosvl

    It should be sth like:

    function get_the_right_one( $link ) {
    	return qtrans_convertURL( $link );
    }
    add_filter( 'xxx', 'get_the_right_one' );

    but I can not find the right “xxx”.

    I tried almost all applied filters. No luck.
    Any help is truly appreciated.

    Plugin Author Jeff Farthing

    @jfarthing84

    You’ll probably want to apply it to tml_page_link.

    Nitroweb

    @spyrosvl

    Hello Jeff,

    Thanks for the quick reply.
    I have this on my theme-my-login-custom.php as I have read your previous posts.

    function tml_page_link_filter( $link ) {
        return qtrans_convertURL( $link );
      }
      add_filter( 'tml_page_link', 'tml_page_link_filter' );

    It still misses the selected language.

    Regards,
    Spyros

    Plugin Author Jeff Farthing

    @jfarthing84

    Which link are we talking about? The profile link?

    Nitroweb

    @spyrosvl

    Hi Jeff,

    The form on the ?action=profile page.
    It will redirect to the default language after posting.

    Regards,
    Spyros

    Plugin Author Jeff Farthing

    @jfarthing84

    Add a higher priority to the filter:

    add_filter( 'tml_page_link', 'tml_page_link_filter', 20 );

    @jfarthing84 I’m sorry but this is not working.
    Any more suggestions?
    I would not like to “fork” your plugin. I know that would be totally wrong.
    Thanks in advance.

    Spyros

    Plugin Author Jeff Farthing

    @jfarthing84

    The code simply adds updated=true to the current URL when the profile form is posted. So, if you’re on the profile form with a language already appended to the URL, it should stay there.

    @jfarthing84 Indeed, I can see that, BUT trying to debug I concluded that the language settings have been changed before getting to the function by adding:

    function tml_page_link_filter( $link ) {
        exit(qtrans_getLanguage());
        return qtrans_convertURL( $link , $_POST['lang']);
      }
      add_filter( 'tml_page_link', 'tml_page_link_filter', 20);

    On exit it returns the default language, not the one selected. 🙁

    ignore the $_POST['lang'] from above… error on paste

    I came up with this solution:

    function tml_page_link_filter( $link ) {
        return qtrans_convertURL( $link);
      }
      add_filter( 'tml_page_link', 'tml_page_link_filter', 20); 
    
      function tml_wp_redirect( $link ) {
        return qtrans_convertURL( $link);
      }
      add_filter( 'wp_redirect', 'tml_wp_redirect', 20);

    Thanks Hostdog! Jeff’s function wasn’t working for me either but your solution seems to do the trick.

    None of the above solutions are working for me. There must have been serious change to TML recently. All other translate functions work on my site except for TML. running WP 3.52 with TML Version 6.3.8.

    Putting the custom.php in causes the php code to be echoed at the top of all pages. Am I inserting it wrong?

    Update: I added standard php tags and it doesn’t echo anymore. Just doesn’t do a darned thing.

    I’m using the last suggested fix, BTW. No joy.

Viewing 15 replies - 1 through 15 (of 16 total)
  • The topic ‘[Resolved] [PATCH] qTranslate support for forms that are redirected after submission’ is closed to new replies.
Skip to toolbar