Using WordPress ‘before_signup_header’ PHP action

The before_signup_header WordPress PHP action fires before the Site Sign-up page is loaded.

Usage

add_action('before_signup_header', 'your_custom_function');

function your_custom_function() {
    // your custom code here
}

Parameters

  • None

More information

See WordPress Developer Resources: before_signup_header

Examples

Change the Site Sign-up page title

Customize the title of the Site Sign-up page:

add_action('before_signup_header', 'change_signup_page_title');

function change_signup_page_title() {
    // Change the title
    add_filter('wp_title', function() {
        return 'Custom Site Sign-up Title';
    });
}

Add a custom message to the Site Sign-up page

Display a custom message above the sign-up form:

add_action('before_signup_header', 'add_custom_message');

function add_custom_message() {
    // Add a custom message
    echo '<div class="custom-message">Welcome to our site! Please sign up below.</div>';
}

Redirect users to a custom registration page

Redirect users to a custom registration page if they are not logged in:

add_action('before_signup_header', 'redirect_to_custom_registration');

function redirect_to_custom_registration() {
    // Check if user is logged in
    if (!is_user_logged_in()) {
        // Redirect to custom registration page
        wp_redirect('https://example.com/custom-registration');
        exit;
    }
}

Add custom CSS to the Site Sign-up page

Add custom CSS styles to the Site Sign-up page:

add_action('before_signup_header', 'add_custom_signup_css');

function add_custom_signup_css() {
    // Add custom CSS
    echo '<style>
        body { background-color: #f5f5f5; }
        .custom-message { font-size: 18px; color: #333; }
    </style>';
}

Load a custom JavaScript file on the Site Sign-up page

Enqueue a custom JavaScript file on the Site Sign-up page:

add_action('before_signup_header', 'load_custom_js');

function load_custom_js() {
    // Enqueue custom JavaScript file
    wp_enqueue_script('custom-signup-js', 'https://example.com/js/custom-signup.js', array('jquery'), '1.0', true);
}