The gform_user_registration_new_site_meta filter allows you to modify the site meta while creating a new site using Gravity Forms PHP.
Usage
add_filter('gform_user_registration_new_site_meta', 'your_function_name', 10, 6);
Parameters
- $site_meta (array): An array of new site arguments (e.g. if the site is public => 1).
- $form (array): The form object.
- $entry (array): The entry object.
- $feed (array): The feed object.
- $user_id (int): The ID of the user who creates the site.
- $is_update_feed (boolean): True/false indicator of whether this is a feed to update an existing setup.
More information
See Gravity Forms Docs: gform_user_registration_new_site_meta
Examples
Set a Blog Template ID
This example sets the blog template ID to 1 when creating a new site.
add_filter('gform_user_registration_new_site_meta', 'add_blog_template', 10, 6); function add_blog_template($site_meta, $form, $entry, $feed, $user_id, $is_update_feed) { $site_meta['blog_template'] = 1; return $site_meta; }
Set the Site Language
This example sets the site language to Spanish when creating a new site.
add_filter('gform_user_registration_new_site_meta', 'set_site_language', 10, 6); function set_site_language($site_meta, $form, $entry, $feed, $user_id, $is_update_feed) { $site_meta['WPLANG'] = 'es_ES'; return $site_meta; }
Make the Site Private
This example makes the new site private when creating a new site.
add_filter('gform_user_registration_new_site_meta', 'make_site_private', 10, 6); function make_site_private($site_meta, $form, $entry, $feed, $user_id, $is_update_feed) { $site_meta['public'] = 0; return $site_meta; }
Add Custom Site Meta
This example adds custom site meta when creating a new site.
add_filter('gform_user_registration_new_site_meta', 'add_custom_site_meta', 10, 6); function add_custom_site_meta($site_meta, $form, $entry, $feed, $user_id, $is_update_feed) { $site_meta['custom_key'] = 'custom_value'; return $site_meta; }
Modify Site Meta Based on Form Data
This example modifies the site meta based on form data when creating a new site.
add_filter('gform_user_registration_new_site_meta', 'modify_site_meta_based_on_form', 10, 6); function modify_site_meta_based_on_form($site_meta, $form, $entry, $feed, $user_id, $is_update_feed) { if ($entry['1'] == 'yes') { $site_meta['public'] = 1; } else { $site_meta['public'] = 0; } return $site_meta; }