How to Read settings from the file

I am working on a plugin that exports article metadata to json files. Part of the code is using fopen function but it fails on some installations with permission denied errors because it attempts to crate the file in the plugin’s folder.


     $json_file = fopen("submission_{$submission_id}.json", "w") or die("Unable to open file!");

    fwrite($json_file, $json_file_contents);



I am currently searching through the code on how to read the files_dir setting from file and have not been lucky so far. I will appreciate any help. Thanks

Hi @otuomasp

There’s a static class that makes this easy. Example:

Config::getVar('general', 'base_url');

The first parameter is the [section] you want to read from, the second is the setting name.


@jnugent Perfect solution. Asante sana!

1 Like