
<script>
document.querySelectorAll('.affiliate-eligible-check').forEach(function(checkbox) {
    console.log('Checkbox ditemukan:', checkbox); // DEBUG
    checkbox.addEventListener('change', function() {
        console.log('Checkbox berubah'); // DEBUG
        var userId = this.getAttribute('data-user-id');
        var nonce = this.getAttribute('data-nonce');
        var ajaxUrl = this.getAttribute('data-ajax-url');
        var checked = this.checked;

        console.log('Data:', {userId, nonce, ajaxUrl, checked}); // DEBUG

        var fd = new FormData();
        fd.append('action', 'roboedu_toggle_affiliate_eligible');
        fd.append('user_id', userId);
        fd.append('nonce', nonce);
        fd.append('checked', checked ? 'true' : 'false');

        fetch(ajaxUrl, {
            method: 'POST',
            credentials: 'include',
            body: fd
        }).then(r => r.json()).then(function(res) {
            console.log('Response:', res); // DEBUG
            if (res.success) {
                console.log('Berhasil disimpan:', userId);
            } else {
                alert('Error: ' + res.data);
                checkbox.checked = !checked;
            }
        }).catch(function(err) {
            console.error('Fetch error:', err); // DEBUG
            alert('Connection error');
            checkbox.checked = !checked;
        });
    });
});
</script>

<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="https://roboedutrade.com/wp-sitemap-index.xsl" ?>
<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"><sitemap><loc>https://roboedutrade.com/wp-sitemap-posts-post-1.xml</loc></sitemap><sitemap><loc>https://roboedutrade.com/wp-sitemap-posts-page-1.xml</loc></sitemap><sitemap><loc>https://roboedutrade.com/wp-sitemap-posts-product-1.xml</loc></sitemap><sitemap><loc>https://roboedutrade.com/wp-sitemap-posts-sfwd-courses-1.xml</loc></sitemap><sitemap><loc>https://roboedutrade.com/wp-sitemap-posts-sfwd-lessons-1.xml</loc></sitemap><sitemap><loc>https://roboedutrade.com/wp-sitemap-posts-sfwd-quiz-1.xml</loc></sitemap><sitemap><loc>https://roboedutrade.com/wp-sitemap-taxonomies-category-1.xml</loc></sitemap><sitemap><loc>https://roboedutrade.com/wp-sitemap-taxonomies-product_cat-1.xml</loc></sitemap><sitemap><loc>https://roboedutrade.com/wp-sitemap-taxonomies-ld_course_category-1.xml</loc></sitemap><sitemap><loc>https://roboedutrade.com/wp-sitemap-users-1.xml</loc></sitemap></sitemapindex>
