• Resolved davidian34

    (@davidian34)


    I need some help to know where to search in the code in order to solve this problem:

    When I’m logged in as say user Paul and navigate to another user profile by typing /user-profile/testguy1/ for example, everything works as expected and that user’s (testguy1) info is loaded from the wp_usermeta table correctly.

    However, if I type the page spanish version url: /es/perfil/?um_user=testguy1, the query var name is ignored and the page shows the current logged in user info, not testguy1’s info.

    Where can I found the code that I need to change so the backend includes the spanish version url as a valid one in which the um_user query var can be recognized and then the correct data fetched from the DB?

    Also, if I navigate to the the spanish page with the um_user prettylink name: /es/perfil/testguy1/ the page is not found.

    Then how can I rewrite that url with prettylinks (I’ve tried it in functions.php as I do with other pages that are my own templates not UM pages with no success).

    Thank you!!!

Viewing 7 replies - 1 through 7 (of 7 total)
  • Plugin Contributor Champ Camba

    (@champsupertramp)

    Hi @davidian34

    You need to use a translation plugin to make it work. You can check this doc for translating the plugin:
    https://docs.ultimatemember.com/article/1449-how-to-translate-plugin

    Regards,

    Thread Starter davidian34

    (@davidian34)

    Hmmm, I was talking about another language url so yes of course I use a plugin to translate, it’s Polylang. I’ve tried TranslatePress, it does a good job translating and with the urls but sends heavy requests to the database that cause 100% CPU spikes on a little server so I don’t like it.

    That’s why i use Polylang but it causes the problems I mentioned in the first post…

    This is the Polylang support response:

    We had a look at the source code of the Ultimate Member plugin a while ago and noticed that this plugin can't work, out of the box, with Polylang, I'm afraid buying the Pro version won't solve the situation for you.
    
    The multilingual compatibility that this plugin developed can work only for WPML as this plugin uses internal functions of WPML (direct calls to methods of the $sitepress object) instead of the the official WPML API. The WPML internal function are unfortunately not handled by Polylang, only the official WPML API are. They are listed here => https://github.com/polylang/polylang/blob/master/modules/wpml/wpml-api.php.

    I asked WPML if their plugin would be fully compatible with yours and they told me no.

    So I wish you could help with the questions I had in the first place, thanks!

    Thread Starter davidian34

    (@davidian34)

    I just need to know where the user-profile url is handled in the profile page with the query var and I then could add the other languages profile urls to do the job.

    Knowing where this function is called and passes the $slug would help:

    * Get Profile Permalink
    *
    * @param string $slug
    * @return string $profile_url
    */
    function profile_permalink( $slug ) {}

    Thanks!

    • This reply was modified 3 years, 9 months ago by davidian34.
    Plugin Contributor Champ Camba

    (@champsupertramp)

    Hi @davidian34

    Unfortunately, there’s a lot to look at and modify. I couldn’t locate where you can add the slug where you can add your custom language URL parameter. I’ll let you know when I found it.

    You can try looking at the files: class-permalinks.php, class-user.php and class-profile.php

    Regards,

    Thread Starter davidian34

    (@davidian34)

    Hi @champsupertramp!

    Thanks, I’ve been checking the call stack and I reached the function locate_user_profile() in the file

    class-rewrite.php

    where I think the stuff is happening.

    I’ll let you know where and how I fix it!

    Thanks again.

    Thread Starter davidian34

    (@davidian34)

    Hi, so I’m stuck here:

    With the query var ?um_user everything works fine now in the english version and in the other languages when I type /user-profile/?um_user=paul or /es/perfil/?um_user=paul or any name.

    Basically what I did is adding this code inside the foreach in the get_core_pages() function of the class-config.php file, because it was setting the $permalink[ $page_key ] to the english page key: (I know it’s a fast fix, but I have no time)

    if($page_key == ‘user’){
    $url = “//{$_SERVER[‘HTTP_HOST’]}{$_SERVER[‘REQUEST_URI’]}”;
    $country_slug = explode(‘/’, $url)[3];
    if($country_slug == ‘es’){
    $permalink[ $page_key ] = 795;
    }
    elseif($country_slug == ‘fr’){
    $permalink[ $page_key ] = 884;
    }
    }

    But if I type /es/perfil/paul/, the global $post variable in the function um_is_core_page of the um_short_function file is empty and the page is not found:

    function um_is_core_page( $page ) {
    global $post;
    if ( empty( $post ) ) {
    echo(’empty post global variable’);
    return false;
    }

    Everything works fine with the english version with any name (/user-profile/paul/).

    Why the $post variable is empty with the other languages urls with prettylinks?

    Thanks!

    • This reply was modified 3 years, 9 months ago by davidian34.
    Thread Starter davidian34

    (@davidian34)

    Quick fix done!

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Profile page in another language’ is closed to new replies.