Title: Custom_Image_Header::take_action
Published: April 25, 2014
Last modified: April 28, 2025

---

# Custom_Image_Header::take_action()

## In this article

 * [Source](https://developer.wordpress.org/reference/classes/custom_image_header/take_action/?output_format=md#source)
 * [Related](https://developer.wordpress.org/reference/classes/custom_image_header/take_action/?output_format=md#related)
 * [Changelog](https://developer.wordpress.org/reference/classes/custom_image_header/take_action/?output_format=md#changelog)

[ Back to top](https://developer.wordpress.org/reference/classes/custom_image_header/take_action/?output_format=md#wp--skip-link--target)

Executes custom header modification.

## 󠀁[Source](https://developer.wordpress.org/reference/classes/custom_image_header/take_action/?output_format=md#source)󠁿

    ```php
    public function take_action() {
    	if ( ! current_user_can( 'edit_theme_options' ) ) {
    		return;
    	}

    	if ( empty( $_POST ) ) {
    		return;
    	}

    	$this->updated = true;

    	if ( isset( $_POST['resetheader'] ) ) {
    		check_admin_referer( 'custom-header-options', '_wpnonce-custom-header-options' );

    		$this->reset_header_image();

    		return;
    	}

    	if ( isset( $_POST['removeheader'] ) ) {
    		check_admin_referer( 'custom-header-options', '_wpnonce-custom-header-options' );

    		$this->remove_header_image();

    		return;
    	}

    	if ( isset( $_POST['text-color'] ) && ! isset( $_POST['display-header-text'] ) ) {
    		check_admin_referer( 'custom-header-options', '_wpnonce-custom-header-options' );

    		set_theme_mod( 'header_textcolor', 'blank' );
    	} elseif ( isset( $_POST['text-color'] ) ) {
    		check_admin_referer( 'custom-header-options', '_wpnonce-custom-header-options' );

    		$_POST['text-color'] = str_replace( '#', '', $_POST['text-color'] );

    		$color = preg_replace( '/[^0-9a-fA-F]/', '', $_POST['text-color'] );

    		if ( strlen( $color ) === 6 || strlen( $color ) === 3 ) {
    			set_theme_mod( 'header_textcolor', $color );
    		} elseif ( ! $color ) {
    			set_theme_mod( 'header_textcolor', 'blank' );
    		}
    	}

    	if ( isset( $_POST['default-header'] ) ) {
    		check_admin_referer( 'custom-header-options', '_wpnonce-custom-header-options' );

    		$this->set_header_image( $_POST['default-header'] );

    		return;
    	}
    }
    ```

[View all references](https://developer.wordpress.org/reference/files/wp-admin/includes/class-custom-image-header.php/)
[View on Trac](https://core.trac.wordpress.org/browser/tags/6.9.4/src/wp-admin/includes/class-custom-image-header.php#L212)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/6.9.4/src/wp-admin/includes/class-custom-image-header.php#L212-L264)

## 󠀁[Related](https://developer.wordpress.org/reference/classes/custom_image_header/take_action/?output_format=md#related)󠁿

| Uses | Description | 
| [Custom_Image_Header::reset_header_image()](https://developer.wordpress.org/reference/classes/custom_image_header/reset_header_image/)`wp-admin/includes/class-custom-image-header.php` |

Resets a header image to the default image for the theme.

  | 
| [Custom_Image_Header::remove_header_image()](https://developer.wordpress.org/reference/classes/custom_image_header/remove_header_image/)`wp-admin/includes/class-custom-image-header.php` |

Removes a header image.

  | 
| [Custom_Image_Header::set_header_image()](https://developer.wordpress.org/reference/classes/custom_image_header/set_header_image/)`wp-admin/includes/class-custom-image-header.php` |

Chooses a header image, selected from existing uploaded and default headers, or provides an array of uploaded header data (either new, or from media library).

  | 
| [set_theme_mod()](https://developer.wordpress.org/reference/functions/set_theme_mod/)`wp-includes/theme.php` |

Updates theme modification value for the active theme.

  | 
| [check_admin_referer()](https://developer.wordpress.org/reference/functions/check_admin_referer/)`wp-includes/pluggable.php` |

Ensures intent by verifying that a user was referred from another admin page with the correct security nonce.

  | 
| [current_user_can()](https://developer.wordpress.org/reference/functions/current_user_can/)`wp-includes/capabilities.php` |

Returns whether the current user has the specified capability.

  |

[Show 1 more](https://developer.wordpress.org/reference/classes/custom_image_header/take_action/?output_format=md#)
[Show less](https://developer.wordpress.org/reference/classes/custom_image_header/take_action/?output_format=md#)

## 󠀁[Changelog](https://developer.wordpress.org/reference/classes/custom_image_header/take_action/?output_format=md#changelog)󠁿

| Version | Description | 
| [2.6.0](https://developer.wordpress.org/reference/since/2.6.0/) | Introduced. |

## User Contributed Notes

You must [log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Fclasses%2Fcustom_image_header%2Ftake_action%2F)
before being able to contribute a note or feedback.