Hooks ഉപയോഗ ഗൈഡ്
Ultimate Multisite-ൽ 200-ൽ അധികം ആക്ഷൻ Hooks-ഉം 280-ൽ അധികം ഫിൽട്ടർ Hooks-ഉം ലഭ്യമാണ്. ഏറ്റവും സാധാരണയായി ഉപയോഗിക്കുന്ന Hooks-കൾ പ്രായോഗിക ഉദാഹരണങ്ങളോടുകൂടി ഈ പേജിൽ ഉൾപ്പെടുത്തിയിരിക്കുന്നു. പൂർണ്ണമായ ഓട്ടോ-ജനറേറ്റഡ് റഫറൻസിനായി, ഈ വിഭാഗത്തിലെ മറ്റ് പേജുകൾ പരിശോധിക്കുക.
ആക ്ഷൻ Hooks (Action Hooks)
ഉപഭോക്തൃ ജീവിതചക്രം (Customer Lifecycle)
ഉപഭോക്താവ് സൃഷ്ടിച്ചതിന് ശേഷം (After Customer Creation)
/**
* @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!'
);
});
ഉപഭോക്തൃ സ്റ്റാറ്റസ് മാറ്റം (Customer Status Change)
/**
* @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) {
// സ്റ്റാറ്റസ് മാറ്റങ്ങളോട് പ്രതികരിക്കുക
}, 10, 3);
സൈറ്റ് Hooks (Site Hooks)
സൈറ്റ് പ്രസിദ്ധീകരിച്ചതിന് ശേഷം (After Site Published)
/**
* @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);
ടെംപ്ലേറ്റ് അ പ്ലയി ചെയ്യുന്നതിന് മുമ്പ് (Before Template Application)
/**
* @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);
മെമ്പർഷിപ്പ് Hooks (Membership Hooks)
സ്റ്റാറ്റസ് ട്രാൻസിഷനുകൾ (Status Transitions)
add_action('wu_membership_status_to_active', function($membership) {
// മെമ്പർഷിപ്പ് സജീവമാക്കി
});
add_action('wu_membership_status_to_expired', function($membership) {
$sites = $membership->get_sites();
foreach ($sites as $site) {
$site->set_status('suspended');
$site->save();
}
});
പേയ്മെന്റ് Hooks (Payment Hooks)
പേയ്മെന്റ് പൂർത്തിയായതോ പരാജയപ്പെട്ടതോ (Payment Completed / Failed)
add_action('wu_payment_completed', function($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);
ചെക്ക്ഔട്ട് Hooks (Checkout Hooks)
പ്രോസസ്സ് ചെയ്യുന്നതിന് മുമ്പ് / പൂർത്തിയാക്കിയ ശേഷം (Before Processing / After Completion)
/**
* @param WP_Ultimo\Checkout\Cart $cart
*/
add_action('wu_checkout_before_processing', function($cart) {
// പ്രോസസ്സ് ചെയ്യുന്നതിന് മുമ്പ് കാർട്ട് സാധൂകരിക്കുകയോ മാറ്റങ്ങൾ വരുത്തുകയോ ചെയ്യുക
});
/**
* @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) {
// കൺവേർഷൻ ട്രാക്ക് ചെയ്യുക, അറിയിപ്പുകൾ അയക്കുക, തുടങ്ങിയ കാര്യങ്ങൾ ചെയ്യുക
}, 10, 3);
ഡൊമെയ്ൻ Hooks (Domain Hooks)
add_action('wu_domain_mapped', function($domain) {
// CDN അല്ലെങ്കിൽ DNS കോൺഫിഗറേഷൻ അപ്ഡേറ്റ് ചെയ്യുക
});
add_action('wu_domain_ssl_verified', function($domain) {
// ഡൊമെയ്നിന് SSL സർട്ടിഫിക്കറ്റ് പരിശോധിച്ചു
});