Title: PHP Warning: Creating default object from empty value
Last modified: August 21, 2016

---

# PHP Warning: Creating default object from empty value

 *  [jules2000](https://wordpress.org/support/users/jules2000/)
 * (@jules2000)
 * [12 years, 8 months ago](https://wordpress.org/support/topic/php-warning-creating-default-object-from-empty-value-2/)
 * I am getting this warning. Any advice?
 * Warning: Creating default object from empty value in /home/d2hosts/public_html/
   Marathoncountymfg.org/wp-content/plugins/gravity-forms-addons/gravity-forms-addons.
   php on line 266
 * [http://wordpress.org/plugins/gravity-forms-addons/](http://wordpress.org/plugins/gravity-forms-addons/)

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

 *  Thread Starter [jules2000](https://wordpress.org/support/users/jules2000/)
 * (@jules2000)
 * [12 years, 8 months ago](https://wordpress.org/support/topic/php-warning-creating-default-object-from-empty-value-2/#post-4048954)
 * There seems to be a conflict with the All-in-One Event Calendar by Timely plugin.
   The error message goes away when I deactivate that plugin. However since this
   site is live and requires the functionality of both plugins – I tried commenting
   out the line that is prompting the error (266):
    global $post; $post->permalink
   = $permalink; $url = add_query_arg(array());
 * The error went away and everything is still working but this clearly isn’t a 
   long term solution. Any advice?
 *  [jhoffmcd](https://wordpress.org/support/users/jhoffmcd/)
 * (@jhoffmcd)
 * [12 years, 8 months ago](https://wordpress.org/support/topic/php-warning-creating-default-object-from-empty-value-2/#post-4049025)
 * [@jules2000](https://wordpress.org/support/users/jules2000/),
 * I am having the exact same issue with a different events plugin: [Event Espresso](http://eventespresso.com/)
 * I found the same thing, if I comment out that line then the error goes away, 
   although right now I have no idea how this would affect my directories. I believe
   the function that this is in is canonical_directories… If I can trace that down
   and see what function that serves then maybe I can figure out a work around. 
   I’ll let you know.
 *  [jhoffmcd](https://wordpress.org/support/users/jhoffmcd/)
 * (@jhoffmcd)
 * [12 years, 8 months ago](https://wordpress.org/support/topic/php-warning-creating-default-object-from-empty-value-2/#post-4049028)
 * I added this as a fix, and it seems to work…
 *     ```
       global $post;
   
               // Had to nest this in order to avoid conflicts with other plugins
               if($post != null) {
                   $post->permalink = $permalink;
                   $url = add_query_arg(array());
                   $sentPostID = is_object($sentPost) ? $sentPost->ID : $sentPost;
                   // $post->ID === $sentPostID is so that add_query_arg match doesn't apply to prev/next posts; just current
                   preg_match('/('.sanitize_title(apply_filters('kws_gf_directory_endpoint', 'entry')).'\/([0-9]+)(?:\/|-)([0-9]+)\/?)/ism',$url, $matches);
                   if(isset($post->ID) && $post->ID === $sentPostID && !empty($matches)) {
                       return trailingslashit($permalink).$matches[0];
                   } elseif(isset($post->ID) && $post->ID === $sentPostID && (isset($_REQUEST['leadid']) && isset($_REQUEST['form'])) || !empty($matches)) {
                       if($matches)  { $leadid = $matches[2]; $form = $matches[1]; }
                       else { $leadid = $_REQUEST['leadid']; $form = $_REQUEST['form']; }
   
                       return add_query_arg(array('leadid' =>$leadid, 'form'=>$form), trailingslashit($permalink));
                   }
                   return $permalink;
               }
       ```
   
 * Hopefully this doesn’t hamper the use of the directory…
 *  [jhoffmcd](https://wordpress.org/support/users/jhoffmcd/)
 * (@jhoffmcd)
 * [12 years, 8 months ago](https://wordpress.org/support/topic/php-warning-creating-default-object-from-empty-value-2/#post-4049029)
 * I should note that this was in the gravity-forms-addons.php file at line 266.
   I wrapped almost everything in a condition that checks for a post object.
 *  [spiderbiteman](https://wordpress.org/support/users/spiderbiteman/)
 * (@spiderbiteman)
 * [11 years, 9 months ago](https://wordpress.org/support/topic/php-warning-creating-default-object-from-empty-value-2/#post-4049080)
 * Needs one more bracket –> } at the end or will bomb out.
 * Also, the only time I received the error was when I have all in one event calendar
   enabled, turn that off and the error goes away. It’s NOT with all in one event
   calendar, but instead with Gravity Forms Directory, but the solution jhoffmcd
   offers solves that problem.
 * Thanks!

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

The topic ‘PHP Warning: Creating default object from empty value’ is closed to new
replies.

 * ![](https://ps.w.org/gravity-forms-addons/assets/icon-256x256.jpg?rev=996787)
 * [Gravity Forms Directory](https://wordpress.org/plugins/gravity-forms-addons/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/gravity-forms-addons/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/gravity-forms-addons/)
 * [Active Topics](https://wordpress.org/support/plugin/gravity-forms-addons/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/gravity-forms-addons/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/gravity-forms-addons/reviews/)

 * 5 replies
 * 3 participants
 * Last reply from: [spiderbiteman](https://wordpress.org/support/users/spiderbiteman/)
 * Last activity: [11 years, 9 months ago](https://wordpress.org/support/topic/php-warning-creating-default-object-from-empty-value-2/#post-4049080)
 * Status: not resolved