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.
July 4, 2018 at 1:33 am #14944
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.
$language_file = "/path/to/your/custom/language/file/lang.php";
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 #78080clem90Member
Can I use this code with WPML and eMember WPML Addon ?August 4, 2018 at 11:01 pm #78081
You should be able to. I have never tested it so I can’t say for sure.January 9, 2020 at 11:08 pm #78082drjansonMember
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?
thanks.January 11, 2020 at 1:26 am #78083
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
If you echo the value of the following constant, it will give you the path to the emember plugin:
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 #78085drjansonMember
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
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:
$language_file = "/../../themes/customizr-pro-child/ger_custom.php";
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
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.phpSeptember 13, 2020 at 4:16 pm #78087
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?
$language_file = “/home/username/public_html/wp-content/plugins/wp-emember-child-lang/hun.php”;
}September 13, 2020 at 9:06 pm #78088
Are you sure about the absolute file path?September 14, 2020 at 8:16 pm #78089
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
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:
<?php echo '<p>Hello World</p>'; ?>
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:
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
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:
The result was:
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
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.
?>September 15, 2020 at 4:03 pm #78093
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”:
- You must be logged in to reply to this topic.