Title: Problem with php code to remove author page
Last modified: March 27, 2020

---

# Problem with php code to remove author page

 *  [nootkan](https://wordpress.org/support/users/nootkan/)
 * (@nootkan)
 * [6 years, 2 months ago](https://wordpress.org/support/topic/problem-with-php-code-to-remove-author-page/)
 * I found this [**code**](https://wordpress.2bearstudio.com/disable-wordpress-author-pages/)
   while browsing the forum and implemented it inside my child-theme>>functions.
   php file and it seems to work.
 *     ```
       add_action('template_redirect', 'my_custom_disable_author_page');
   
       function my_custom_disable_author_page() {
       	global $wp_query;
   
       	if ( is_author() ) {
       		$wp_query->set_404();
       		status_header(404);
       		// Redirect to homepage
       		// wp_redirect(get_option('home'));
       	}
       }
       ```
   
 * However, I keep seeing this warning in my error logs:
 * > PHP Warning: call_user_func_array() expects parameter 1 to be a valid callback,
   > function ‘remove_author_pages_page’ not found or invalid function name in /
   > home/mywebsite/public_html/wp-includes/class-wp-hook.php on line 288
 * Can anyone shed some light on what I may have done wrong?
    Thanks

Viewing 5 replies - 1 through 5 (of 5 total)

 *  [munyagu](https://wordpress.org/support/users/munyagu/)
 * (@munyagu)
 * [6 years, 2 months ago](https://wordpress.org/support/topic/problem-with-php-code-to-remove-author-page/#post-12594412)
 * Hi,
 * Remove
    `add_action( 'template_redirect', 'remove_author_pages_page' );`.
 * It’s exists another line in function.php.
 * Didn’t you copy and paste this code together?
 *  Thread Starter [nootkan](https://wordpress.org/support/users/nootkan/)
 * (@nootkan)
 * [6 years, 2 months ago](https://wordpress.org/support/topic/problem-with-php-code-to-remove-author-page/#post-12596255)
 * Thanks for your reply. I did copy and paste the code and the extra add_action
   was there. I just omitted it when posting here for some reason.
 * In any case your solution did the trick. It now redirects to 404 without the 
   warnings.
 * Thanks again for your support.
 *  Thread Starter [nootkan](https://wordpress.org/support/users/nootkan/)
 * (@nootkan)
 * [6 years, 2 months ago](https://wordpress.org/support/topic/problem-with-php-code-to-remove-author-page/#post-12596317)
 * One more question if you don’t mind?
 * I would like to now have it redirect to the home page instead of 404 page.
 * The example states that I just have to comment out the two lines for the 404 
   redirect and uncomment the wp_redirect which I did.
 * It still redirects to a 404 page and I was wondering if there is another way 
   to achieve what I want?
 * Thanks again for your support.
 *     ```
       function my_custom_disable_author_page() {
       	global $wp_query;
   
       	if ( is_author() ) {
       		// $wp_query->set_404();
       		// status_header(404);
       		// Redirect to homepage
       		wp_redirect(get_option('home'));
       	}
       }
   
       add_action('template_redirect', 'my_custom_disable_author_page');
       ```
   
 *  [munyagu](https://wordpress.org/support/users/munyagu/)
 * (@munyagu)
 * [6 years, 2 months ago](https://wordpress.org/support/topic/problem-with-php-code-to-remove-author-page/#post-12600499)
 * [@nootkan](https://wordpress.org/support/users/nootkan/)
 * You must `exit` after `wp_redirect`.
 *     ```
       wp_redirect(get_option('home'));
       exit();
       ```
   
    -  This reply was modified 6 years, 2 months ago by [munyagu](https://wordpress.org/support/users/munyagu/).
 *  Thread Starter [nootkan](https://wordpress.org/support/users/nootkan/)
 * (@nootkan)
 * [6 years, 2 months ago](https://wordpress.org/support/topic/problem-with-php-code-to-remove-author-page/#post-12603869)
 * Once again thank you for replying it is greatly appreciated.
 * I did try using exit; as per this link: [function wp_redirect](https://developer.wordpress.org/reference/functions/wp_redirect/)
 * Even with the parenthesis added as per your solution, it still isn’t working.
 * It seems no matter what I try I get sent to a 404 page every time.
 * I’ve cleared cache, tried several browsers to confirm it wasn’t a cache issue
   and tried various code changes based on google searching.
 * I’ve de-activated/re-activated all plugins one at a time and used ctrl F5 to 
   clear cache but that didn’t show any conflicts with plugins. Did the same for
   the theme.
 * One thing I noticed is when I remove the snippet entirely from the child theme
   >>fuctions.php file the 404 issue still exists.
 * So now I assume there must be another issue and the snippet works.
 * I will keep trying but I may have to settle for the 404 error page (hopefully
   not).
 * Any other ideas that may lead me to a solution?
 * Thanks again for your support!
    -  This reply was modified 6 years, 2 months ago by [nootkan](https://wordpress.org/support/users/nootkan/).
      Reason: added more content

Viewing 5 replies - 1 through 5 (of 5 total)

The topic ‘Problem with php code to remove author page’ is closed to new replies.

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 5 replies
 * 2 participants
 * Last reply from: [nootkan](https://wordpress.org/support/users/nootkan/)
 * Last activity: [6 years, 2 months ago](https://wordpress.org/support/topic/problem-with-php-code-to-remove-author-page/#post-12603869)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
