Hot answers tagged

3

wp_insert_post was introduced in changeset 2887, and was to fix bug #1681. I couldn't find the save_post hook's original provenance, but it was most recently added to core in changeset 3291, related to ticket #2063. Evidently it had existed in 1.5.2 (although version control does not support this theory) and needed to be added back for back-compat. So ...


1

I have been looking around the core files searching for hooks, there were very few when it comes to hooking into edit_user() function which updates the user data in profile.php page, so I have finished with some workarounds: My workaround is to save the user's password in a custom option before the password was updated, and match later with this user's ...


1

Since the paste has worked perfect for you, let me turn it into an answer. You can always get the author of a given post with certain methods, let's use get_post_field( 'post_author', $post_id ) for this. To get the data of a given user, there's get_userdata() function to use. We'll pass the author ID as first param to this function to get the author data ...


1

The global $authordata variable is only available by default when $wp_query->is_author() && isset($wp_query->post) condition is satisfied. It means that you can't access $authordata inside a single post page. You may try to get author data via $wp_query: add_action('wp_head', function() { global $wp_query; $userdata = get_userdata(...


1

If you want to use a variable from a another context in a function, create a class: class CustomLog { private $debug_msg = ""; public function __construct( $msg ) { $this->debug_msg = $msg; } public function log() { error_log( $this->debug_msg, 0 ); } } add_action( 'init', [ new CustomLog( "Hi there!" ), '...



Only top voted, non community-wiki answers of a minimum length are eligible