Using WordPress ‘add_signup_meta’ PHP filter

The add_signup_meta WordPress PHP filter allows you to modify the default site meta variables during the site signup process.

Usage

add_filter('add_signup_meta', 'your_custom_function');
function your_custom_function($meta) {
    // Your custom code here
    return $meta;
}

Parameters

  • $meta (array): An array of default site meta variables.
    • lang_id (int): The language ID.
    • blog_public (int): Whether search engines should be discouraged from indexing the site. 1 for true, 0 for false.

More information

See WordPress Developer Resources: add_signup_meta

Examples

Change default language ID

Change the default language ID for new sites during the signup process.

add_filter('add_signup_meta', 'change_default_language_id');
function change_default_language_id($meta) {
    $meta['lang_id'] = 2; // Set the default language ID to 2
    return $meta;
}

Discourage search engines by default

Set new sites to discourage search engines from indexing them by default.

add_filter('add_signup_meta', 'discourage_search_engines');
function discourage_search_engines($meta) {
    $meta['blog_public'] = 0; // Discourage search engines from indexing
    return $meta;
}

Add custom site meta variable

Add a custom site meta variable during the signup process.

add_filter('add_signup_meta', 'add_custom_meta_variable');
function add_custom_meta_variable($meta) {
    $meta['custom_variable'] = 'custom_value'; // Add custom site meta variable
    return $meta;
}

Change multiple meta variables

Change multiple default meta variables during the signup process.

add_filter('add_signup_meta', 'change_multiple_meta_variables');
function change_multiple_meta_variables($meta) {
    $meta['lang_id'] = 2; // Change language ID
    $meta['blog_public'] = 0; // Discourage search engines from indexing
    return $meta;
}

Remove a meta variable

Remove a default meta variable during the signup process.

add_filter('add_signup_meta', 'remove_meta_variable');
function remove_meta_variable($meta) {
    unset($meta['lang_id']); // Remove the default language ID
    return $meta;
}