Title: Error plugin
Last modified: December 16, 2021

---

# Error plugin

 *  Resolved [Neo](https://wordpress.org/support/users/firefliespilots/)
 * (@firefliespilots)
 * [4 years, 5 months ago](https://wordpress.org/support/topic/error-plugin-19/)
 * Hi, still installation and activation I get this error. What exactly does this
   mean? Thanks a lot
 * `Fatal error: Uncaught TypeError: fclose(): Argument #1 ($stream) must be of 
   type resource, bool given in /var/www/html/site/public_html/wp-content/plugins/
   wpforo/wpf-includes/functions.php:843 Stack trace: #0 /var/www/html/site/public_html/
   wp-content/plugins/wpforo/wpf-includes/functions.php(843): fclose(false) #1 /
   var/www/html/site/public_html/wp-content/plugins/wpforo/wpf-includes/wpf-hooks.
   php(1267): wpforo_write_file('/var/www/html/s...', 'window.wpforo_p...') #2 /
   var/www/html/site/public_html/wp-content/plugins/wpforo/wpf-includes/wpf-hooks.
   php(1302): wpforo_dynamic_phrases_register() #3 /var/www/html/site/public_html/
   wp-includes/class-wp-hook.php(303): wpforo_frontend_register_scripts('') #4 /
   var/www/html/site/public_html/wp-includes/class-wp-hook.php(327): WP_Hook->apply_filters(
   NULL, Array) #5 /var/www/html/site/public_html/wp-includes/plugin.php(470): WP_Hook-
   >do_action(Array) #6 /var/www/html/site/public_html/wp-includes/script-loader.
   php(2083): do_action('wp_enqueue_scri...') #7 /var/www/html/site/public_html/
   wp-includes/class-wp-hook.php(303): wp_enqueue_scripts('') #8 /var/www/html/site/
   public_html/wp-includes/class-wp-hook.php(327): WP_Hook->apply_filters(NULL, 
   Array) #9 /var/www/html/site/public_html/wp-includes/plugin.php(470): WP_Hook-
   >do_action(Array) #10 /var/www/html/site/public_html/wp-includes/general-template.
   php(3015): do_action('wp_head') #11 /var/www/html/site/public_html/wp-content/
   themes/my-listing/header.php(8): wp_head() #12 /var/www/html/site/public_html/
   wp-includes/template.php(770): require_once('/var/www/html/s...') #13 /var/www/
   html/site/public_html/wp-includes/template.php(716): load_template('/var/www/
   html/s...', true, Array) #14 /var/www/html/site/public_html/wp-includes/general-
   template.php(48): locate_template(Array, true, true, Array) #15 /var/www/html/
   site/public_html/wp-content/themes/my-listing/page.php(1): get_header() #16 /
   var/www/html/site/public_html/wp-includes/template-loader.php(106): include('/
   var/www/html/s...') #17 /var/www/html/site/public_html/wp-blog-header.php(19):
   require_once('/var/www/html/s...') #18 /var/www/html/site/public_html/index.php(
   6): require('/var/www/html/s...') #19 {main} thrown in /var/www/html/site/public_html/
   wp-content/plugins/wpforo/wpf-includes/functions.php on line 843`

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

 *  Plugin Support [gVectors Dev](https://wordpress.org/support/users/gvectorsdevs/)
 * (@gvectorsdevs)
 * [4 years, 5 months ago](https://wordpress.org/support/topic/error-plugin-19/#post-15169958)
 * Hi [@firefliespilots](https://wordpress.org/support/users/firefliespilots/)
    
   Go to: /wp-content/plugins/wpforo/wpf-includes/ open functions.php file,
 * find the below code:
    `function wpforo_write_file(`
 * And replace the code with the below one:
 *     ```
       function wpforo_write_file( $new_file, $content ) {
          $return = array( 'error' => '', 'file' => '' );
          $new_file = wpforo_fix_dir_sep( $new_file );
          $dir = dirname( $new_file );
          if( !is_dir( $dir ) ) wp_mkdir_p($dir);
          $ifp    = @fopen( $new_file, 'wb' );
          if( ! $ifp ) {
             if( is_resource( $ifp ) ) {
                @fclose( $ifp );
             }
             $return = array( 'error' => sprintf( __( 'Could not write file %s' ), $new_file ) );
          } else {
             @fwrite( $ifp, $content );
             fclose( $ifp );
             clearstatcache();
             // Set correct file permissions
             $stat  = @stat( dirname( $new_file ) );
             $perms = $stat['mode'] & 0007777;
             $perms = $perms & 0000666;
             @chmod( $new_file, $perms );
             clearstatcache();
             $return['file'] = $new_file;
          }
   
          return $return;
       }
       ```
   
 * Also, this is temporary, the issue will be solved in the new 2.0 version.
 *  Thread Starter [Neo](https://wordpress.org/support/users/firefliespilots/)
 * (@firefliespilots)
 * [4 years, 5 months ago](https://wordpress.org/support/topic/error-plugin-19/#post-15169969)
 * Hi [@gvectorsdevs](https://wordpress.org/support/users/gvectorsdevs/) , ok, thank
   you very much. I will try it right away. When is the next version coming? Thanks
   a lot
 *  Thread Starter [Neo](https://wordpress.org/support/users/firefliespilots/)
 * (@firefliespilots)
 * [4 years, 5 months ago](https://wordpress.org/support/topic/error-plugin-19/#post-15170031)
 * Hi [@gvectorsdevs](https://wordpress.org/support/users/gvectorsdevs/),
 * is not working
 * `Fatal error: Uncaught Error: Call to undefined function wpforo_fix_dir_sep()
   in /var/www/html/site/public_html/wp-content/plugins/wpforo/wpf-includes/functions.
   php:841 Stack trace: #0 /var/www/html/site/public_html/wp-content/plugins/wpforo/
   wpf-includes/wpf-hooks.php(1267): wpforo_write_file('/var/www/html/s...', 'window.
   wpforo_p...') #1 /var/www/html/site/public_html/wp-content/plugins/wpforo/wpf-
   includes/wpf-hooks.php(1302): wpforo_dynamic_phrases_register() #2 /var/www/html/
   site/public_html/wp-includes/class-wp-hook.php(303): wpforo_frontend_register_scripts('')#
   3 /var/www/html/site/public_html/wp-includes/class-wp-hook.php(327): WP_Hook-
   >apply_filters(NULL, Array) #4 /var/www/html/site/public_html/wp-includes/plugin.
   php(470): WP_Hook->do_action(Array) #5 /var/www/html/site/public_html/wp-includes/
   script-loader.php(2083): do_action('wp_enqueue_scri...') #6 /var/www/html/site/
   public_html/wp-includes/class-wp-hook.php(303): wp_enqueue_scripts('') #7 /var/
   www/html/site/public_html/wp-includes/class-wp-hook.php(327): WP_Hook->apply_filters(
   NULL, Array) #8 /var/www/html/site/public_html/wp-includes/plugin.php(470): WP_Hook-
   >do_action(Array) #9 /var/www/html/site/public_html/wp-includes/general-template.
   php(3015): do_action('wp_head') #10 /var/www/html/site/public_html/wp-content/
   themes/my-listing/header.php(8): wp_head() #11 /var/www/html/site/public_html/
   wp-includes/template.php(770): require_once('/var/www/html/s...') #12 /var/www/
   html/site/public_html/wp-includes/template.php(716): load_template('/var/www/
   html/s...', true, Array) #13 /var/www/html/site/public_html/wp-includes/general-
   template.php(48): locate_template(Array, true, true, Array) #14 /var/www/html/
   site/public_html/wp-content/themes/my-listing/page.php(1): get_header() #15 /
   var/www/html/site/public_html/wp-includes/template-loader.php(106): include('/
   var/www/html/s...') #16 /var/www/html/site/public_html/wp-blog-header.php(19):
   require_once('/var/www/html/s...') #17 /var/www/html/site/public_html/index.php(
   6): require('/var/www/html/s...') #18 {main} thrown in /var/www/html/site/public_html/
   wp-content/plugins/wpforo/wpf-includes/functions.php on line 841`
 *  Plugin Support [gVectors Dev](https://wordpress.org/support/users/gvectorsdevs/)
 * (@gvectorsdevs)
 * [4 years, 5 months ago](https://wordpress.org/support/topic/error-plugin-19/#post-15170074)
 * [@firefliespilots](https://wordpress.org/support/users/firefliespilots/),
 * The Function which needs to be replaced start with
    `function wpforo_write_file(`
   and it ends with
 *     ```
       return $return;
       }
       ```
   
 * So you need to replace the whole function
    Please check the below screenshot 
   [⌊2021-12-16_17-47-02⌉](https://www.screencast.com/t/MdJAi17tIW)
 *  Thread Starter [Neo](https://wordpress.org/support/users/firefliespilots/)
 * (@firefliespilots)
 * [4 years, 5 months ago](https://wordpress.org/support/topic/error-plugin-19/#post-15170668)
 * Hi [@gvectorsdevs](https://wordpress.org/support/users/gvectorsdevs/) i have 
   it
 *     ```
       function wpforo_write_file( $new_file, $content ) {
          $return = array( 'error' => '', 'file' => '' );
          $new_file = wpforo_fix_dir_sep( $new_file );
          $dir = dirname( $new_file );
          if( !is_dir( $dir ) ) wp_mkdir_p($dir);
          $ifp    = @fopen( $new_file, 'wb' );
          if( ! $ifp ) {
             if( is_resource( $ifp ) ) {
                @fclose( $ifp );
             }
             $return = array( 'error' => sprintf( __( 'Could not write file %s' ), $new_file ) );
          } else {
             @fwrite( $ifp, $content );
             fclose( $ifp );
             clearstatcache();
             // Set correct file permissions
             $stat  = @stat( dirname( $new_file ) );
             $perms = $stat['mode'] & 0007777;
             $perms = $perms & 0000666;
             @chmod( $new_file, $perms );
             clearstatcache();
             $return['file'] = $new_file;
          }
       	return $return;
       }
       ```
   
 *  Plugin Support [gVectors Dev](https://wordpress.org/support/users/gvectorsdevs/)
 * (@gvectorsdevs)
 * [4 years, 5 months ago](https://wordpress.org/support/topic/error-plugin-19/#post-15170920)
 * [@firefliespilots](https://wordpress.org/support/users/firefliespilots/),
 * Add the below code After the last code I gave you. the code must start on a new
   line and must have an empty line at his top and bottom,
 *     ```
        function wpforo_fix_dir_sep($dir){
           $dir = str_replace( array('/', '\\', '\\\\'), DIRECTORY_SEPARATOR, $dir );
           return rtrim( trim($dir), DIRECTORY_SEPARATOR );
        }
       ```
   
 *  Thread Starter [Neo](https://wordpress.org/support/users/firefliespilots/)
 * (@firefliespilots)
 * [4 years, 5 months ago](https://wordpress.org/support/topic/error-plugin-19/#post-15171137)
 * Hi [@gvectorsdevs](https://wordpress.org/support/users/gvectorsdevs/), no problem.(-;
   I have added it below. Now I have a parse error
 * line 867: return rtrim( trim($dir), DIRECTORY_SEPARATOR );
 * ————————————————————–
 * function wpforo_write_file( $new_file, $content ) {
    $return = array( ‘error’
   => ”, ‘file’ => ” ); $new_file = wpforo_fix_dir_sep( $new_file ); $dir = dirname(
   $new_file ); if( !is_dir( $dir ) ) wp_mkdir_p($dir); $ifp = @fopen( $new_file,‘
   wb’ ); if( ! $ifp ) { if( is_resource( $ifp ) ) { @fclose( $ifp ); } $return 
   = array( ‘error’ => sprintf( __( ‘Could not write file %s’ ), $new_file ) ); }
   else { @fwrite( $ifp, $content ); fclose( $ifp ); clearstatcache(); // Set correct
   file permissions $stat = [@stat](https://wordpress.org/support/users/stat/)( 
   dirname( $new_file ) ); $perms = $stat[‘mode’] & 0007777; $perms = $perms & 0000666;
   [@chmod](https://wordpress.org/support/users/chmod/)( $new_file, $perms ); clearstatcache();
   $return[‘file’] = $new_file; } return $return; }
 * function wpforo_fix_dir_sep($dir){
    $dir = str_replace( array('/', '\\', '\\\\'),
   DIRECTORY_SEPARATOR, $dir ); return rtrim( trim($dir), DIRECTORY_SEPARATOR );}
 * —————————————————————————–
 *     ```
       Parse error: syntax error, unexpected token "return" in /var/www/html/site/public_html/wp-content/plugins/wpforo/wpf-includes/functions.php on line 867
   
       Notice: is_page was called incorrectly. Conditional query tags do not work before the query is run. Before then, they always return false. Please see Debugging in WordPress for more information. (This message was added in version 3.1.0.) in /var/www/html/site/public_html/wp-includes/functions.php on line 5663
   
       Notice: is_singular was called incorrectly. Conditional query tags do not work before the query is run. Before then, they always return false. Please see Debugging in WordPress for more information. (This message was added in version 3.1.0.) in /var/www/html/site/public_html/wp-includes/functions.php on line 5663
   
       Notice: is_embed was called incorrectly. Conditional query tags do not work before the query is run. Before then, they always return false. Please see Debugging in WordPress for more information. (This message was added in version 3.1.0.) in /var/www/html/site/public_html/wp-includes/functions.php on line 5663
   
       Notice: is_search was called incorrectly. Conditional query tags do not work before the query is run. Before then, they always return false. Please see Debugging in WordPress for more information. (This message was added in version 3.1.0.) in /var/www/html/site/public_html/wp-includes/functions.php on line 5663
       ```
   
    -  This reply was modified 4 years, 5 months ago by [Neo](https://wordpress.org/support/users/firefliespilots/).
 *  Plugin Support [gVectors Dev](https://wordpress.org/support/users/gvectorsdevs/)
 * (@gvectorsdevs)
 * [4 years, 5 months ago](https://wordpress.org/support/topic/error-plugin-19/#post-15171181)
 * [@firefliespilots](https://wordpress.org/support/users/firefliespilots/),
    Please
   provide a screenshot of the full code with last changes.
 * You copied the code from mail or from wordpress forum?
 *  Thread Starter [Neo](https://wordpress.org/support/users/firefliespilots/)
 * (@firefliespilots)
 * [4 years, 5 months ago](https://wordpress.org/support/topic/error-plugin-19/#post-15171227)
 * Dear [@gvectorsdevs](https://wordpress.org/support/users/gvectorsdevs/), I have
   copied it out here. But I have now again quickly written in manually and now 
   it runs. Super. Do you already have a date when the update will come? Thank you
 *  Plugin Support [gVectors Dev](https://wordpress.org/support/users/gvectorsdevs/)
 * (@gvectorsdevs)
 * [4 years, 5 months ago](https://wordpress.org/support/topic/error-plugin-19/#post-15172575)
 * [@firefliespilots](https://wordpress.org/support/users/firefliespilots/),
    It
   may be in the first half of 2022

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

The topic ‘Error plugin’ is closed to new replies.

 * ![](https://ps.w.org/wpforo/assets/icon-256x256.png?rev=2121644)
 * [wpForo Forum](https://wordpress.org/plugins/wpforo/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/wpforo/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/wpforo/)
 * [Active Topics](https://wordpress.org/support/plugin/wpforo/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/wpforo/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/wpforo/reviews/)

 * 10 replies
 * 2 participants
 * Last reply from: [gVectors Dev](https://wordpress.org/support/users/gvectorsdevs/)
 * Last activity: [4 years, 5 months ago](https://wordpress.org/support/topic/error-plugin-19/#post-15172575)
 * Status: resolved