Woocommerce Login Redirect not working

I am currently trying to change Woocommerce redirect url for login only when users logged from a specific page. So first I tried that way in my template page:

<?php woocommerce_login_form(array('redirect'=>$_SERVER['REQUEST_URI'])); ?>

Then, I saw user is still redirected to default (my-account) so I used the login hook that way:

function share_login_redirect( $redirect ) {
    if( strtr($_SERVER['REQUEST_URI'],array('/partage','/share')) ){
        $redirect = get_site_url().$_SERVER['REQUEST_URI'];
    return $redirect;
add_filter( 'woocommerce_login_redirect', 'share_login_redirect', 10, 2 );

All of thoses techniques didn’t work for me. Knowing that $redirect = "https://mysite/share/?param=xx" what am I doing wrong there?

2017-08-29 EDIT : If anyone had the same problem as I did, it is possible a plugin uses the same hook than you and have an higher priority than yours meaning the redirect will not work until you move up your priority. Please see my answer below.

Solutions Collecting From Web of "Woocommerce Login Redirect not working"

Try changing strtr to strpos. However, you can not give it an array for needles I don’t think. You will have to create another function for that.

function strposa($haystack, $needles=array(), $offset=0) {
        $chr = array();
        foreach($needles as $needle) {
                $res = strpos($haystack, $needle, $offset);
                if ($res !== false) $chr[$needle] = $res;
        if(empty($chr)) return false;
        return min($chr);

Use this function instead of strtr

I found what was my problem is priority. Some other plugin was using a 1000 priority, so I had to boost my priority when declaring the hook. That way:

add_filter( 'woocommerce_login_redirect', 'share_login_redirect', 1100, 2 );

instead of

add_filter( 'woocommerce_login_redirect', 'share_login_redirect', 10, 2 );