हुक्स का उपयोग कैसे करें
Ultimate Multisite 200 से अधिक एक्शन हुक्स और 280 से अधिक फ़िल्टर हुक्स प्रदान करता है। यह पेज सबसे ज़्यादा इस्तेमाल होने वाले हुक्स को व्यावहारिक उदाहरणों के साथ कवर करता है। एक संपूर्ण ऑटो-जनरेटेड संदर्भ के लिए, इस सेक्शन के अन्य पेजों को देखें।
एक्शन हुक्स
ग्राहक जीवनचक्र
ग्राहक बनने के बाद
/**
* @param WP_Ultimo\Models\Customer $customer
*/
add_action('wu_customer_post_create', function($customer) {
wp_mail(
$customer->get_email(),
'Welcome!',
'Thanks for joining our platform!'
);
});
ग्राहक की स्थिति में बदलाव
/**
* @param WP_Ultimo\Models\Customer $customer
* @param string $old_status
* @param string $new_status
*/
add_action('wu_customer_status_change', function($customer, $old_status, $new_status) {
// React to status transitions
}, 10, 3);
साइट हुक्स
साइट प्रकाशित होने के बाद
/**
* @param WP_Ultimo\Models\Site $site
* @param WP_Ultimo\Models\Membership $membership
*/
add_action('wu_site_published', function($site, $membership) {
switch_to_blog($site->get_id());
activate_plugin('essential-plugin/essential-plugin.php');
restore_current_blog();
}, 10, 2);
टेम्पलेट लागू होने से पहले
/**
* @param int $site_id
* @param int $template_id
*/
add_action('wu_before_apply_template', function($site_id, $template_id) {
switch_to_blog($site_id);
if ($template_id === 5) {
update_option('woocommerce_store_setup', 'complete');
}
restore_current_blog();
}, 10, 2);
सदस्यता हुक्स
स्थिति परिवर्तन
add_action('wu_membership_status_to_active', function($membership) {
// Membership activated
});
add_action('wu_membership_status_to_expired', function($membership) {
$sites = $membership->get_sites();
foreach ($sites as $site) {
$site->set_status('suspended');
$site->save();
}
});
भुगतान हुक्स
भुगतान पूरा/असफल
add_action('wu_payment_completed', function($payment) {
// Handle successful payment
});
add_action('wu_payment_failed', function($payment, $error_message) {
$admin_email = get_option('admin_email');
wp_mail(
$admin_email,
'Payment Failed',
sprintf('Payment #%d failed: %s', $payment->get_id(), $error_message)
);
}, 10, 2);
चेकआउट हुक्स
प्रोसेसिंग से पहले / पूरा होने के बाद
/**
* @param WP_Ultimo\Checkout\Cart $cart
*/
add_action('wu_checkout_before_processing', function($cart) {
// Validate or modify cart before processing
});
/**
* @param WP_Ultimo\Models\Payment $payment
* @param WP_Ultimo\Models\Customer $customer
* @param WP_Ultimo\Models\Membership $membership
*/
add_action('wu_checkout_completed', function($payment, $customer, $membership) {
// Track conversion, send notifications, etc.
}, 10, 3);