751 posts
  • Has been part of the Envato Community for over 6 years
  • Has referred 1+ members
  • Has collected 10+ items on Envato Market
  • Sells items exclusively on Envato Market
+1 more
CyberShot says

after updating to Wordpress 3.5, I got this error only on one of my sites but not the other test site running the same theme. Odd isn’t it?

http://pastebin.com/rNR7sMGP

I don’t know what the issue is. This is the error WordPress is giving me

Notice: Undefined index: eventmeta_noncename in /home3/themes/savior/functions.php on line 1399

3472 posts
  • Elite Author: Sold more than $75,000 on Envato Market
  • Has sold $750,000+ on Envato Market
  • Located in United States
  • Helps us moderate the forums
+10 more
sevenspark Moderator says

It’s just a PHP Warning, not going to hurt anything.

The theme should just be testing

isset( $_POST['eventmeta_noncename'] )

before accessing the array at that key directly.

You’ll only get that warning under certain circumstances, since sometimes the POST var will be present and other times it won’t be.

If I follow the logic correctly, I think it should be:

if ( !isset( $_POST['eventmeta_noncename'] ) || !wp_verify_nonce( $_POST['eventmeta_noncename'], plugin_basename(__FILE__) )) {
    return $post->ID;
}
751 posts
  • Has been part of the Envato Community for over 6 years
  • Has referred 1+ members
  • Has collected 10+ items on Envato Market
  • Sells items exclusively on Envato Market
+1 more
CyberShot says

You followed it correctly. That fixed it. Thank you

3472 posts
  • Elite Author: Sold more than $75,000 on Envato Market
  • Has sold $750,000+ on Envato Market
  • Located in United States
  • Helps us moderate the forums
+10 more
sevenspark Moderator says

You’re welcome

244 posts
  • Has been part of the Envato Community for over 3 years
  • Has referred 10+ members
  • Has sold $10,000+ on Envato Market
  • Has collected 1+ items on Envato Market
+2 more
dmsumon says

You’re welcome

Sir! You are a WP super star. Thank you …

158 posts
  • Has been part of the Envato Community for over 5 years
  • Has referred 50+ members
  • Has sold $1,000+ on Envato Market
  • Sells items exclusively on Envato Market
+1 more
greenshady says

This is probably a bit more than what you wanted, but here’s a breakdown of all the things you need to fix other than what’s already been mentioned.

For the wpt_events_date() function:

I’m assuming you’re properly adding the meta box via add_meta_box(). Doing so will pass the $post object directly to your function as the first parameter, so there’s no need for the global $post.

You should use the wp_nonce_field() function to create your nonce input instead of hardcoding the HTML for it.

You need to escape the $month and $date variables before adding them as an attribute for your input boxes.

I’d also prefix your name attributes instead of using eventmeta_nonce, _month, and _date in the inputs. Use a unique prefix like wpt_. I’d make sure all things going to $_POST are prefixed so there’s less risk of conflicts with anyone else’s code.

For the wpt_save_events_meta() function:

Use $post_id instead of $post->ID. No biggie, but you already have the data there in variable form.

You should check the edit_post_meta, add_post_meta, and/or delete_post_meta capabilities rather than the edit_post capability. Plus, a hardcoded edit_post is technically wrong; you’d need to use the post type object to check the actual capability, which might be different. But, you don’t need that cap. You need the post meta caps.

All $_POST data should be sanitized/validated before sending it to the database. The month should be sanitized to make sure it’s a one-/two-number value. The date should go through the same process to make sure it’s both the type of data you want and in the correct format.

There’s no need for worrying if the data is an array because a user won’t be passing you an array through a text input box. Nevertheless, with proper validation/sanitization, you wouldn’t need to worry about that anyway.

If you’re going to check if the post type is a revision, it should be done before your foreach loop.

Your if/else and if checks in your foreach loop should be if/elseif/elseif instead.

Helpful Information

  • Please read our community guidelines. Self promotion and discussion of piracy is not allowed.
  • Open a support ticket if you would like specific help with your account, deposits or purchases.
  • Item Support by authors is optional and may vary. Please see the Support tab on each item page.

Most of all, enjoy your time here. Thank you for being a valued Envato community member.

Post Reply

Format your entry with some basic HTML. Read the Full Details, or here is a refresher:

<strong></strong> to make things bold
<em></em> to emphasize
<ul><li> or <ol><li> to make lists
<h3> or <h4> to make headings
<pre></pre> for code blocks
<code></code> for a few words of code
<a></a> for links
<img> to paste in an image (it'll need to be hosted somewhere else though)
<blockquote></blockquote> to quote somebody

:grin: :shocked: :cry: Complete List of Smiley Codes

by
by
by
by
by
by