An echo line in a transition_post_status action leads to “cannot modify header information – headers already sent by”

The error message you are seeing is normal for that operation. By the time the transition_post_status hook fires, the HTTP page headers is already sent. By simply echoing an error message inside a hook like transition_post_status which was never intended to echo any output to the browser, as you did, you are actually trying to … Read more

Modify users.php page to create page/post on button clicked

Use wp-admin/admin.php with an action parameter: <a href=”https://wordpress.stackexchange.com/questions/184153/<?php echo esc_url( admin_url(“admin.php?action=wpse_184153_create_page&user_id=$user_id” ) ) ?>”>Create Page</a> And then hook onto the event: function wpse_184153_create_page() { $redirect = admin_url( ‘users.php’ ); if ( ! empty( $_GET[‘user_id’] ) && $user = get_userdata( ( int ) $_GET[‘user_id’] ) ) { // Create your page // Add any URL parameters … Read more