Support

Account

Home Forums ACF PRO Setting Color Picker as a CSS var

Solving

Setting Color Picker as a CSS var

  • Hello,

    I was wondering if anyone could help me and figuring out why my code will not work? I’m trying to set the color picker value as a CSS var. This was the colors of my site change based on the color the user picked on their profile.

    Thanks!

    <?php function primary_brand_color(){
    $branding = get_field('primary_brand_color', '"user_" . get_current_user_id()');
    echo '<style type="text/css">
    :root{--branding:'.$branding.';}
    </style>';
    }
  • Hi @christianj40

    What does $branding output?

  • If I did it correctly in the code it should output the color picker field in the user’s profile.

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.