bbPress

Simple, Fast, Elegant

bbPress support forums » Plugins

Calling an file in a higher directory from plugin

(5 posts)
  • Started 1 year ago by mouse8b
  • Latest reply from Trent
  • This topic is resolved

Tags:

  1. 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();

    Posted 1 year ago #
  2. 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

    Posted 1 year ago #
  3. Thanks! I didn't think to include the absolute path. I had the path as www.mysite.com/mysite_function.php, but that didn't work. Thanks for pointing that out.

    Posted 1 year ago #
  4. You need to include http:// if you use an absolute path!

    Posted 1 year ago #
  5. Unless you use server path. Either way should work I thinks! lol

    Trent

    Posted 1 year ago #

RSS feed for this topic

Reply

You must log in to post.

Code is Poetry.