Skip Navigation

[Resolved] Is it possible to use custom field to modify a page’s CSS?

This thread is resolved. Here is a description of the problem and solution.

Problem:
Is it possible to use that color picker field to somehow modify the css of elements on my page? In other words, I'd like it to be used to specify header color of the background.

Solution:
Yes, you can use that color picker to change color of specific sections by using class/id selector as follows:

<style type="text/css">
 .new-bg-color,
 .site-content,{
	 background:<?php echo types_render_usermeta( "pick-the-color", array( "user_current" => true ) ); ?>
}
</style>

In the above code, please replace “pick-the-color” to your color picker field slug.

You can add above code in header.php file and then use ‘new-bg-color’ class in page builder Custom Class section.

Relevant Documentation:
https://toolset.com/documentation/customizing-sites-using-php/functions/#colorpicker

This support ticket is created 6 years, 11 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Our next available supporter will start replying to tickets in about 1.71 hours from now. Thank you for your understanding.

Sun Mon Tue Wed Thu Fri Sat
- 12:00 – 17:00 12:00 – 17:00 12:00 – 17:00 12:00 – 17:00 12:00 – 17:00 -
- 18:00 – 21:00 18:00 – 21:00 18:00 – 21:00 18:00 – 21:00 18:00 – 21:00 -

Supporter timezone: Asia/Karachi (GMT+05:00)

This topic contains 2 replies, has 2 voices.

Last updated by joseL-6 6 years, 10 months ago.

Assisted by: Noman.

Author
Posts
#602489

My site will allow users (companies) to have their own areas with content visible only to them.
I have 2 custom user fields that specify a logo (image field) and a color (color picker field) for each user (customer).

Is it possible to use that color picker field to somehow modify the css of elements on my page? In other words, I'd like it to be used to specify header color of the background color of certain modules, for example (I'm using Beaver Builder also).

Would appreciate any guidance on this.

#602527

Noman
Supporter

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

Hi Jose,

Thank you for contacting Toolset support. Yes, you can use that color picker to change color of specific sections by using class/id selector as follows:

<style type="text/css">
 .new-bg-color,
 .site-content,{
	 background:<?php echo types_render_usermeta( "pick-the-color", array( "user_current" => true ) ); ?>
}
</style>

In the above code, please replace “pick-the-color” to your color picker field slug.

You can add above code in header.php file and then use ‘new-bg-color’ class in page builder Custom Class section.

https://toolset.com/documentation/customizing-sites-using-php/functions/#colorpicker

Thank you

#605137

Thank you! That's pretty much what I was looking for.