var background = jQuery('.field_background-image p').text(); //get the text from the .field_background-image field (it's wrapped in p tags)
jQuery('body').append('<style>'+background+'</style>'); //append it to the body (change it to prepend if you don't want it to override other css in the body
jQuery('.profile-fields tr.field_background-image').hide(); //hide the table row with the css
</script>
So... looking for a way for those who don't code to add some select elements via the same method but having some trouble.
I want to do something like this:
<script> var background = jQuery('.field_background-image p').text(); //get the text from the .field_background-image field (it's wrapped in p tags) var backgroundcss = body.my-profile{background-image: url('+background+');}.appearance h4{display: none !important;}
jQuery('body').append('<style>'+backgroundcss+'</style>'); //append it to the body (change it to prepend if you don't want it to override other css in the body
jQuery('.profile-fields tr.field_background-image').hide(); //hide the table row with the css </script>
But I am not sure how to do this for var backgroundcss
/** * Formats a profile field according to its type. [ TODO: Should really be moved to filters ] * * @package BuddyPress Core * @param $field_type The type of field: datebox, selectbox, textbox etc * @param $field_value The actual value * @uses bp_format_time() Formats a time value based on the WordPress date format setting * @return $field_value The formatted value */ function xprofile_format_profile_field( $field_type, $field_value ) { if ( !isset( $field_value ) || empty( $field_value ) ) return false;
As you can see I tried to add style to the allowed tags... still striped them. I think it has to do with this function, as does the img url turning to a link:
/** * xprofile_filter_format_field_value() * * Runs stripslashes on XProfile fields. If is field_type is 'datebox' * then the date will be formatted by bp_format_time(). * * @since BuddyPress (1.0) * * @param string $field_value XProfile field_value to be filtered. * @param string $field_type XProfile field_type to be filtered. * * @uses bp_format_time() * * @return string $field_value Filtered XProfile field_value. False on failure. */ function xprofile_filter_format_field_value( $field_value, $field_type = '' ) { if ( !isset( $field_value ) || empty( $field_value ) ) return false;
if ( 'datebox' == $field_type ) {
// If Unix timestamp if ( is_numeric( $field_value ) ) { $field_value = bp_format_time( $field_value, true, false );
// If MySQL timestamp } else { $field_value = bp_format_time( strtotime( $field_value ), true, false ); }
if ( !empty( $values ) ) { foreach ( (array) $values as $value ) { $value = trim( $value );
// If the value is a URL, skip it and just make it clickable. if ( preg_match( '@(https?://([-\w\.]+)+(:\d+)?(/([\w/_\.]*(\?\S+)?)?)?)@', $value ) ) { $new_values[] = make_clickable( $value );
// Is not clickable } else {
// More than 5 spaces if ( count( explode( ' ', $value ) ) > 5 ) { $new_values[] = $value;
No such luck. I want members to be able to style their profile, but WP strips out the style tags so I was trying to do a get element by ID and add the tags like you did. When I tried the script you suggested, nothing showed up in the console for debugging. Also, it turns the img url into a link even if I ad quotes. Here is the structure there:
<trclass="field_2 field_css">
<tdclass="label">CSS</td>
<tdclass="data">
<p>
body {background-color: #00c000 !important;}#masthead {height:75px; background: #000 url(
Comments
I got it!
So... looking for a way for those who don't code to add some select elements via the same method but having some trouble.
I want to do something like this:
But I am not sure how to do this for var backgroundcss
Any help is much appreciated!
Started a topic for this discussion.
HERE GOES>>>
Here is the whole filters page:
http://svn.buddypress.org/trunk/bp-xprofile/bp-xprofile-filters.php
And another piece to that puzzle.
I wish I knew more about filters... and functions. lol
Digging into filters I found this:
As you can see I tried to add style to the allowed tags... still striped them. I think it has to do with this function, as does the img url turning to a link:
Thanks for trying to help me. Still doesn't seem to be doing the trick. My guess is that WP is not going to cooperate.
The raw CSS works if I add it to the member-header.php file. So I am going to see if I can send it there.
No such luck. I want members to be able to style their profile, but WP strips out the style tags so I was trying to do a get element by ID and add the tags like you did. When I tried the script you suggested, nothing showed up in the console for debugging. Also, it turns the img url into a link even if I ad quotes. Here is the structure there:
<tr class="field_2 field_css">
Doesn't look like I can do an if isset either. I'm way out of my element. lol Any ideas of how this could be done another way?
Left this message @ skem but figured there is no notification system there.
Ok, struggling with script again.
I want to take info from a profile field here:
http://angelladesigns.com/area51/members/angella/profile/
You will see the css, and I want to have a script display the style.
Trouble is there is no Id for that particular <td>.
Any suggestions? is it possible to inject one?