Question

I am using the publish_post action to run some checks on a user after their post is published:

$author_ID = ????

add_action('publish_post', 'rhb_check_current_user', 10, $author_ID);

How can I get the original author's ID?

Was it helpful?

Solution

use

add_action('publish_post', 'rhb_check_current_user');

and in your rhb_check_current_user function check using the global $post:

function rhb_check_current_user(){
    global $post;
    $author_id = $post->post_author;
    ...
    ...
}

OTHER TIPS

I think get_currentuserinfo() is what you're looking for.

Licensed under: CC-BY-SA with attribution
Not affiliated with wordpress.stackexchange
scroll top