Possible to have your email?
Mine: [email protected]
Let’s say you have three websites
example.com
– The Main Siteexample.com/site2
– The Site 2example.com/site3
– The Site 3If you want the content of example.com/site2
show as the main site with example.com
domain, you need to change the domain name that is pointed in the database.
wp_blogs
table , swap the domain and path.Update the wp_options
table.
siteurl
and home
and change the URL there.Update the domain in the wp_site
table.
Now in the network admin dashboard, the tag of the main site, if you want to change that, you have to make changes in the wp-config.php
file.
define( 'BLOG_ID_CURRENT_SITE', 1 );
and replace 1 with the blog ID that you want to show as the main site.Make sure to backup your data.
]]>I Think subdirectory
]]>Could you share the screenshot of wp_site
and wp_blogs
table, if possible ?
grazie!!!
]]>Thanks for all
Step 1: OK
Step 2 : When I change the name of the DB, there will no longer be blog_ID=1, how will the system understand? I’d like to assign the new site directly.
Step3:
This one seems complicated to me, can you do some printscreen to help me understand?
Thank you very much for your help.
DDX
PS: Is it possible to write to you privately so as not to overdo my request, I’m not an expert, sorry.
]]>Step 1: First backup all your files and database.
Step 2: Now set the site you want as primary site
blog_id = 1
, which you can find on wp_blogs
.Step 3: Update the wp_site
and wp_sitemeta
table
domain
and path
for your multisite network, and it should reflect the new main site in wp_site
table.site_admins
and ensure that the admin user(s) for the new main site are listed in the wp_sitemeta
table.I currently have 3 multisite websites. Everything works fine. However, I would like the main site to be put on one of the two sites and not on the current one. How do I go about it?
Is it complicated?
I haven’t found a “tick” to assign to another site.
I’m up to date with maintenance.
Thanks for your help.
DDX
]]>In a WordPress Multisite setup, user registration settings are primarily managed at the network level, which can restrict the ability to enable or disable registrations on individual sites. However, there are a couple of approaches you can take to achieve the functionality you desire:
functions.php
file to control registration per site. For example, you can check the current site and conditionally enable or disable registration based on your requirements. Here’s a basic example:phpCopy codeadd_action('wp', function() { if (is_multisite()) { if (get_current_blog_id() == YOUR_SITE_ID) { // Allow registration add_filter('registration_errors', '__return_false'); } } });
Replace YOUR_SITE_ID
with the ID of the site where you want to allow registration.Remember to back up your site before making any changes and test thoroughly. If you have any further questions, feel free to ask!
]]>]]>class MuktoEmailRestrictionHandler {
private $wpdb;
private $table_prefix;
private $target_form_names;
private $submissions_table;
private $values_table;
public function __construct($target_form_names) {
global $wpdb;
$this->wpdb = $wpdb;
$this->table_prefix = $wpdb->prefix;
$this->target_form_names = $target_form_names;
$this->submissions_table = $this->table_prefix . 'e_submissions';
$this->values_table = $this->table_prefix . 'e_submissions_values';
// Register the validate_email method as a callback for the elementor_pro/forms/validation/email action hook.
add_action('elementor_pro/forms/validation/email', array($this, 'validate_email'), 10, 3);
}
/**
* Validate the email address being submitted.
*
* @param array $field The email field data.
* @param \ElementorPro\Modules\Forms\Records\Record $record The form record object.
* @param \ElementorPro\Modules\Forms\Submissions\Ajax_Handler $ajax_handler The AJAX handler object.
*/
public function validate_email($field, $record, $ajax_handler) {
$form_name = $record->get_form_settings('form_name');
// Check if the current form is one of the target forms.
if (!in_array($form_name, $this->target_form_names)) {
return;
}
$invalid_emails = $this->get_submitted_emails($record->get_form_settings('id'), $form_name);
// Check if the email address being submitted is already present in the list of invalid emails.
if (in_array($field['value'], $invalid_emails)) {
$ajax_handler->add_error($field['id'], "You have already submitted with this email!");
}
}
/**
* Retrieve the email addresses that have already been submitted for a specific form.
*
* @param int $form_id The form ID.
* @param string $form_name The name of the form.
* @return array An array of email addresses that have already been submitted for the given form.
*/
private function get_submitted_emails($form_id, $form_name) {
$form_submissions = $this->wpdb->get_results(
$this->wpdb->prepare(
"SELECT id FROM {$this->submissions_table} WHERE form_name = %s",
$form_name
)
);
$form_submission_ids = array_column($form_submissions, 'id');
if (empty($form_submission_ids)) {
return array();
}
$placeholders = rtrim(str_repeat('%d,', count($form_submission_ids)), ',');
$results = $this->wpdb->get_results(
$this->wpdb->prepare(
"SELECT s.value AS email
FROM {$this->values_table} AS s
INNER JOIN (
SELECT submission_id, MAX(id) AS max_id
FROM {$this->values_table}
WHEREkey
= 'email'
GROUP BY submission_id
) AS e ON s.submission_id = e.submission_id AND s.id = e.max_id
WHERE s.submission_id IN ($placeholders)",
$form_submission_ids
)
);
return array_column($results, 'email');
}
}
// Create an instance of the MuktoEmailRestrictionHandler class and pass the array of target form names as an argument.
$email_restriction_handler = new MuktoEmailRestrictionHandler(array('update this form name'));