WordPress.org

Ready to get started?Download WordPress

Forums

Theme My Login
[resolved] [PATCH] qTranslate support for forms that are redirected after submission (17 posts)

  1. Daedalon
    Member
    Posted 1 year ago #

    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/

  2. Jeff Farthing
    Member
    Plugin Author

    Posted 1 year ago #

    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.

  3. spyrosvl
    Member
    Posted 1 year ago #

    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.

  4. Jeff Farthing
    Member
    Plugin Author

    Posted 1 year ago #

    You'll probably want to apply it to tml_page_link.

  5. spyrosvl
    Member
    Posted 1 year ago #

    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

  6. Jeff Farthing
    Member
    Plugin Author

    Posted 1 year ago #

    Which link are we talking about? The profile link?

  7. spyrosvl
    Member
    Posted 1 year ago #

    Hi Jeff,

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

    Regards,
    Spyros

  8. Jeff Farthing
    Member
    Plugin Author

    Posted 1 year ago #

    Add a higher priority to the filter:

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

  9. spyrosvl
    Member
    Posted 1 year ago #

    @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

  10. Jeff Farthing
    Member
    Plugin Author

    Posted 1 year ago #

    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.

  11. spyrosvl
    Member
    Posted 1 year ago #

    @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. :(

  12. spyrosvl
    Member
    Posted 1 year ago #

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

  13. spyrosvl
    Member
    Posted 1 year ago #

    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);
  14. thatwastaxing
    Member
    Posted 1 year ago #

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

  15. interfool
    Member
    Posted 11 months ago #

    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?

  16. interfool
    Member
    Posted 11 months ago #

    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.

  17. tayssir.ch
    Member
    Posted 8 months ago #

    can anyone help me with this issue :( none of those function worked with me

    Hide URL language information for default language.(unchecked)
    Detect the language of the browser and redirect accordingly. (unchecked)

    my problem in Edit Profile

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags

No tags yet.