Skip to:
Content
Pages
Categories
Search
Top
Bottom

Calling an file in a higher directory from plugin

  • @mouse8b

    Member

    On my site, I have a file of general purpose functions in the site root called “mysite_functions.php.” I have WordPress installed in /wordpress, and bbPress installed in /wordpress/bbpress. I have altered wp_setcookie() and wp_clearcookie() in a WordPress plugin. In those two functions, I use require_once('../mysite_functions.php');, and then the function call. It works fine.

    The problem comes in the bbPress plugins. I have a plugin overriding bb_login() and bb_logout(). In each of those functions I use the exact same code to call mysite_functions.php, but I get “failed to open stream: No such file or directory in [file path] [line number]”

    In either case, the functions are unchanged with the exception of appending:

    require_once("../mysite_functions.php");

    call_my_function();

Viewing 4 replies - 1 through 4 (of 4 total)
  • @trent

    Member

    Why not run an absolute path?

    require_once(/var/www/html/mysite_function.php);

    Does that work?

    If it is root bbPress folder, you could use what is in config.php

    require_once( BBPATH . 'mysite_function.php' );

    Should be pretty easy……?

    Trent

    @mouse8b

    Member

    Thanks! I didn’t think to include the absolute path. I had the path as http://www.mysite.com/mysite_function.php, but that didn’t work. Thanks for pointing that out.

    You need to include http:// if you use an absolute path!

    @trent

    Member

    Unless you use server path. Either way should work I thinks! lol

    Trent

Viewing 4 replies - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.
Skip to toolbar