Title: Problem with  require( );
Last modified: August 21, 2016

---

# Problem with require( );

 *  Resolved [kskerp](https://wordpress.org/support/users/kskerp/)
 * (@kskerp)
 * [12 years, 8 months ago](https://wordpress.org/support/topic/problem-with-require/)
 * I edited the code inside: namaste-lms/controllers/shortcodes.php
 * It now displays lesson requirements for non-completed lessons inside a course
   page. It works great; however when I try to save the changes in a new php file
   and use the command require() I am having some problems.
 * I am trying to save the changes in a separate php file (kevin-changes.php) which
   is being saved to:
    (NAMASTE_PATH. “/views/kevin-changes.php”)
 * When I call require(NAMASTE_PATH.”/views/kevin-changes.php”) from inside “namaste-
   lms/controllers/shortcodes.php”
 * The code executes like it should; however, there is code being displayed above
   the text on the course page. Does anyone know what causes this to occur? I am
   not sure if nested require() commands are causing the extraneous code to be displayed
   on the course page or what exactly.
 * [http://wordpress.org/plugins/namaste-lms/](http://wordpress.org/plugins/namaste-lms/)

Viewing 3 replies - 1 through 3 (of 3 total)

 *  Plugin Author [Bob](https://wordpress.org/support/users/prasunsen/)
 * (@prasunsen)
 * [12 years, 8 months ago](https://wordpress.org/support/topic/problem-with-require/#post-4201368)
 * Shortcodes shouldn’t output anything (which is essentially what require does).
   They should instead return contents.
    You can use something like the code below
   to solve this:
 * ob_start();
    require(…..); $content = ob_get_contents(); ob_end_clean(); return
   $content;
 * Also as you have done the customization right in the plugin instead of by using
   the API, you will lose it if you ever upgrade the plugin.
 *  Thread Starter [kskerp](https://wordpress.org/support/users/kskerp/)
 * (@kskerp)
 * [12 years, 8 months ago](https://wordpress.org/support/topic/problem-with-require/#post-4201419)
 * Thanks!! wrapping it with the output buffering is what I needed.
 * As for losing it with when the plugin updates –
 * Won’t the plugin self update when a new one is released?
 * I am going to look at using the API. Is it difficult? I am new to wordpress and
   not sure exactly what can be done using what.
 *  Plugin Author [Bob](https://wordpress.org/support/users/prasunsen/)
 * (@prasunsen)
 * [12 years, 8 months ago](https://wordpress.org/support/topic/problem-with-require/#post-4201427)
 * The plugin updates from the WP admin panel. It’s semi-automated, means that you
   will be notified when there is a new release and you’ll need to click a button
   to apply.
    If you do this, your customization will be lost.

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Problem with require( );’ is closed to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/namaste-lms_b6c7ae.svg)
 * [Namaste! LMS](https://wordpress.org/plugins/namaste-lms/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/namaste-lms/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/namaste-lms/)
 * [Active Topics](https://wordpress.org/support/plugin/namaste-lms/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/namaste-lms/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/namaste-lms/reviews/)

 * 3 replies
 * 2 participants
 * Last reply from: [Bob](https://wordpress.org/support/users/prasunsen/)
 * Last activity: [12 years, 8 months ago](https://wordpress.org/support/topic/problem-with-require/#post-4201427)
 * Status: resolved