Tips and Tricks HQ Support

Support site for Tips and Tricks HQ premium products

  • Home
  • Contact Us
  • Documentation
  • Forum Home
    • Forum
    • Forum Search
    • Forum Login
    • Forum Registration

How to Load the WP eMember's Language File from Another Folder

by

Tips and Tricks HQ Support Portal › Forums › WP eMember › WP eMember F.A.Q/Instructions › How to Load the WP eMember's Language File from Another Folder

Tagged: customization, Language, WP eMember, wpml

  • This topic has 16 replies, 5 voices, and was last updated 2 years, 6 months ago by admin.
Viewing 15 posts - 1 through 15 (of 17 total)
1 2 →
  • Author
    Posts
  • July 4, 2018 at 1:33 am #14944
    admin
    Keymaster

    If you are customizing the text/messages displayed by the eMember plugin then this tweak maybe helpful.

    You can keep your customized copy of the language file in a different folder (outside the plugins folder). Then use the following code to load it (uses the emember_language_loading_override filter).

    That way the changes you make to the language file don’t get overridden if the plugin is updated.

    You would add the following code to your theme’s functions.php file or a custom plugin.

    add_filter('emember_language_loading_override', 'load_my_custom_emember_language');
    function load_my_custom_emember_language()
    {
    $language_file = "/path/to/your/custom/language/file/lang.php";
    include_once($language_file);
    return "custom-file-loaded";
    }

    This ensures that the plugin will always load your custom language file from your custom folder (so the one inside the plugin folder doesn’t matter).

    August 3, 2018 at 2:09 pm #78080
    clem90
    Member

    Hi,

    Thanks !

    Can I use this code with WPML and eMember WPML Addon ?

    August 4, 2018 at 11:01 pm #78081
    admin
    Keymaster

    You should be able to. I have never tested it so I can’t say for sure.

    January 9, 2020 at 11:08 pm #78082
    drjanson
    Member

    I’m sorry, but I think im messing up the file path and do not get that working..

    What would the path be if its called frome child-theme’s function.php and the language file is in the same directory?

    e.g.

    wp-content/themes/my-childtheme/function.php

    and

    wp-content/themes/my-childtheme/lang.php

    thanks.

    January 11, 2020 at 1:26 am #78083
    wzp
    Moderator

    It should be the absolute path to the custom language file. If the path is accessible via an HTTP or HTTPS address, that is “easiest.” Otherwise, figure out the path, starting at the document root of your WordPress instance. You “could” use a relative path to the file, starting from the directory containing the calling file; but as you determined, “it’s hard” to get right the first time.

    January 12, 2020 at 12:22 am #78084
    admin
    Keymaster

    If you echo the value of the following constant, it will give you the path to the emember plugin:

    WP_EMEMBER_PATH

    That can help you back-calculate the path to your theme (since the path upto the “wp-content” folder is going to be the same)

    January 14, 2020 at 2:14 pm #78085
    drjanson
    Member

    In my functions.php i tried an absolute path with no success:

    $language_file = "https://weblab.geronne.de/wp-content/themes/customizr-pro-child/ger_custom.php"

    Next I tried to put my customized language file into the plugins “lang” directory and tried:

    $language_file = "/ger_custom.php";

    Next I echoed the WP_EMEMBER_PATH as suggested and it returned

    “/www/htdocs/myaccount/weblab.geronne.de/wp-content/plugins/wp-eMember”

    and since my child-theme’s location is “/www/htdocs/myaccount/weblab.geronne.de/wp-content/themes/customizr-pro-child”

    i tried the following code in my child-themes functions.php:

    add_filter('emember_language_loading_override', 'load_my_custom_emember_language');
    function load_my_custom_emember_language()
    {
    $language_file = "/../../themes/customizr-pro-child/ger_custom.php";
    include_once($language_file);
    return "custom-file-loaded";
    }

    But still none of the solutions turned out to be working…

    Any suggestions whats going wrong?

    thanks!!!

    January 15, 2020 at 12:34 am #78086
    admin
    Keymaster

    That is not an absolute path. An absolute path should never have the “http” keyword there. An absolute path should look like the following:

    /www/htdocs/myaccount/weblab.geronne.de/wp-content/themes/customizr-pro-child/ger_custom.php

    September 13, 2020 at 4:16 pm #78087
    duncaagnes
    Member

    I’ve inserted the below code (real username is used in the code) into my Enfold-child themes functions.php, but the changes I make in the hun.php do not take affect.

    If I change the hun.php in the original folder, changes appear immediately, so changes in hun.php should be ok. The functions.php language override code works for the theme itself, so the setup of the child theme should be also ok.

    Please help! How can I make this work?

    Inserted code:

    add_filter(’emember_language_loading_override’, ‘load_my_custom_emember_language’);

    function load_my_custom_emember_language()

    {

    $language_file = “/home/username/public_html/wp-content/plugins/wp-emember-child-lang/hun.php”;

    include_once($language_file);

    return “custom-file-loaded”;

    }

    September 13, 2020 at 9:06 pm #78088
    wzp
    Moderator

    Are you sure about the absolute file path?

    September 14, 2020 at 8:16 pm #78089
    duncaagnes
    Member

    My storage provider uses Cpanel. As long as I know, absolute path in Cpanel always starts with /home/username/..

    Cpanel has a built in editor for php files, that shows the path. I copied that and pasted in the code.

    Is there a way to check if the path is correct?

    September 14, 2020 at 11:03 pm #78090
    wzp
    Moderator

    Is there a way to check if the path is correct?

    In the directory /home/username/public_html/wp-content/plugins/wp-emember-child-lang create file hello.html that contains:

    <html>
    <head>
    <title>PHP Test</title>
    </head>
    <body>
    <?php echo '<p>Hello World</p>'; ?>
    </body>
    </html>

    Then see if the URL yoursite/wp-content/plugins/wp-emember-child-lang/hello.html does what we think it should do.

    Next, create file test.html in the same directory, containing:

    <html>
    <div w3-include-html="/home/username/public_html/wp-content/plugins/wp-emember-child-lang/hello.html"></div>
    </html>

    Then see if the URL yoursite/wp-content/plugins/wp-emember-child-lang/test.html does what we think it should do.

    September 15, 2020 at 7:59 am #78091
    duncaagnes
    Member

    Thanks for the quick answer.

    hello.html works (displays “Hello World’; ?>”)

    test.html does not work (blank page appears)

    On the other hand, I created a .php file with the following content, to get the absolute root from server:

    <?php

    echo $_SERVER[“DOCUMENT_ROOT”]

    ?>

    The result was:

    /home/username/public_html

    The root path seems to be ok, but not working for some reason. Any ida, why? Or any other solution?

    September 15, 2020 at 8:23 am #78092
    admin
    Keymaster

    That means the path you are assuming in not correct (it is not finding the script there). You can’t really assume a path.

    Add the following PHP code to your “hello.html” file which will output the current working directory. That will show you the path info. You can then work out the absolute path to the language file.

    <?php
    echo getcwd();
    ?>

    September 15, 2020 at 4:03 pm #78093
    duncaagnes
    Member

    If I put the code in the hello.html, nothing happens, but if I create a .PHP file with the this code alone, ‘<?php echo getcwd(); ?>’ it provides the exect same result I’m using in “test.html” and “functions.php”:

    /home/username/public_html/wp-content/plugins/wp-emember-child-lang

    It seems,

  • Author
    Posts
Viewing 15 posts - 1 through 15 (of 17 total)
1 2 →
  • You must be logged in to reply to this topic.
Log In

Forum Related

  • Forum Home
  • Forum Search
  • Forum Login

Support Related Forms

  • Contact Us
  • Customer Support
  • Request a Plugin Update
  • Request Fresh Download Links

Useful Links

  • Plugin Upgrade Instructions
  • WP eStore Documentation
  • WP eMember Documentation
  • WP Affiliate Platform Documentation
  • WP PDF Stamper Documentation
  • WP Photo Seller Documentation
  • Tips and Tricks HQ Home Page
  • Our Projects

Quick Setup Video Tutorials

  • WP eStore Video Tutorial
  • WP eMember Video Tutorial
  • WP Affiliate Platform Video Tutorial
  • Lightbox Ultimate Video Tutorial
  • WP Photo Seller Video Tutorial

Our Other Plugins

  • WP Express Checkout
  • Stripe Payments Plugin
  • Simple Download Monitor

Copyright © 2023 | Tips and Tricks HQ