ஹூக்குகள் பயன்பாட்டு வழிகாட்டி
Ultimate Multisite ஆனது 200-க்கும் மேற்பட்ட action hooks மற்றும் 280-க்கும் மேற்பட்ட filter 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) {
// React to status transitions
}, 10, 3);
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);
Membership Hooks (உறுப்பினர் ஹூக்குகள்)
Status Transitions (நிலை மாற்றங்கள்)
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();
}
});