Theme / Divi change visitor css and site logo and all site urls based on REQUEST_URI non logged in wp user

Ok, I managed to get this far and hope it helps someone else a bit… so I solved the non-logged-in user issue like this (in theme functions.php or in my case my plugin functions)

function first_visit(){

    $ip = $_SERVER['REMOTE_ADDR'];
    $value = get_option($ip);

    if ($value == '') {                 
        
        update_option($ip,1); // test
        $affiliate = basename($_SERVER['REQUEST_URI']); // in my case is site.com/signup/whatevercompany which returns whatevercompany
        update_option($ip,$affiliate); // writesoption key = ip and whatevercompany as value to site options table
        
    }                       

} 


/**** so in case user not logged in i get the referral name from wp_options table ****/

    $user_query = new WP_User_Query( $args );
    $user_ID = get_current_user_id(); 

    if ( !$user_ID) {

        first_visit();      
        $ip = $_SERVER['REMOTE_ADDR'];
        $affiliate = get_option($ip);

        if ($affiliate == '') { 
            $affiliate="default"; //set to a default.css/logo
            update_option($ip,$affiliate);          
        }       
        
        $affiliatelogo ='/branding/'.$affiliate.'/logo.png';
        $affiliatecss="/branding/".$affiliate.'/custom.css';       
    }
    
    
/***** then in my themes (DIVI) child theme header file i add this .... this loads the css for that whatevercompany name ****/


function my_theme_enqueue_styles() {
    wp_enqueue_style( 'parent-style', get_template_directory_uri() . '/style.css' );
}

add_action( 'wp_enqueue_scripts', 'my_theme_enqueue_styles' );

/* Load child theme stylesheet with query string */

function enqueue_child_style() {
    $style = get_stylesheet_directory() . '/style.css';
    $cache_buster = date("YmdHi", filemtime( $style ) );
    wp_dequeue_style('divi-style');
    wp_deregister_style('divi-style');
    }
    
    add_action('wp_enqueue_scripts', 'enqueue_child_style', 15);

    $path="";
    wp_enqueue_style( 'css-customer', esc_url($path.'/branding/'.$affiliate.'/custom.css' ));

Now I’m trying to append any link or URL in site (slugs) say from (until at least user is registered and signed up)

mysite.com/product/topup30gb/ to mysite.com/product/topup30gb/go/affiliate/

I have tested above and so far so good… I will have to clean up site options after user proceeds and registers via buying the product by deleting keys for his IP in site meta also all empty keys… once he signs up I add his referrer to his user meta.

deneme bonusudeneme bonusu veren sitelerpulibet girişOnwin Güncel Giriştürkçe altyazılı pornocanlı bahis casino