WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

First time posting here...

I am trying to figure out if there is a hook or action that I can use when a user goes to wp-admin/post.php... Basically when the user goes to post.php I want to check if there is a &from=1 variable and add that to post_meta


$from = $_GET['from'];
$post_id = $_GET['post'];
if($from == 1){
  add_post_meta($post_id, 'EDITED', 'true');
share|improve this question
up vote 1 down vote accepted

You can add your code to the init action hook and check global $pagenow variable:

add_action( 'init', 'wpse8170_check_from_var' );
function wpse8170_check_from_var() {
    global $pagenow;

    if ( 'post.php' != $pagenow || ! isset( $_GET['post'] ) || ! isset( $_GET['from'] ) || 1 != (int) $_GET['from'] ) {

    update_post_meta( (int) $_GET['post'], 'EDITED', 'true' );
share|improve this answer
Updated your code. Removed the pull get_post() as the check is not needed because if the post id doesn't exist update_post_meta() will take care of that. Also took care of your if statements so no longer deeply nested. – Brady Jun 8 '12 at 15:07
thanks @Brady, you are right – Eugene Manuilov Jun 8 '12 at 15:10
Thanks guys! your both awesome – Greg Jun 8 '12 at 15:42
Why did you re-edit and add {} to the if statement? They are not needed if the code running, when the condition is met, is one line only. – Brady Jun 8 '12 at 15:43
@Brady I prefer to use brace even for one line only. It enhances readability and makes code styles look the same. – Eugene Manuilov Jun 8 '12 at 16:16

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.