You can use an xprofile field, I see no harm in it.
Of course, there are other ways.
I believe, by default, all xprofile fields under “Base” are required.
If you don’t want it required, create a new xprofile group to house this new field.
To check the xprofile value of this new field, you’ll have to do a little manipulation in PHP with it. You could use substr() to check for file extensions.
r-a-y’s right, but I can’t help but feel that what you’re proposing could potentially be trouble with regards to XSS and people trying to break your site.
Another approach, with different benefits and drawbacks, would be to utilise either WordPress 2.9’s custom post types or just upload a number of background images using the Media Uploader; you’d still use the xProfile field to get users to select which image they want, but you write some code that switches the image selected with the actual image URL from the media library.
Forgot to mention if you’re going with the xprofile field route, you should check the mime-type for the URL.
This would provide some additional security.
DJPaul’s idea is good as well!
Hi guys,
thanks for the ideas. So far I got this running:
<?php if ( bp_has_profile('profile_group_id=2') ) : ?>
<?php while ( bp_profile_groups() ) : bp_the_profile_group(); ?>
<?php if ( bp_profile_group_has_fields() ) : ?>
<?php while ( bp_profile_fields() ) : bp_the_profile_field(); ?>
<?php if ( bp_field_has_data() ) : ?>
style="<?php bp_the_profile_field_value() ?>"
<?php endif; ?>
<?php endwhile; ?>
<?php endif; ?>
<?php endwhile; ?>
<?php else: ?>
<?php endif;?>
And this indeed outputs the desired value, but it is also wrapped in a paragraph and autolinked. Please do note that I have no idea what I am doing here, weather it is valid, good or anything else, this just got the job done, so it’s a starting point.
I have searched the forum and found this code that is supposed to remove the autolinking:
<?php
function remove_links(){
remove_filter( 'bp_get_the_profile_field_value', 'xprofile_filter_link_profile_data', 2 );
}
add_action( 'plugins_loaded', 'remove_links' );
?>
However it doesn’t do that once placed in bp-custom.php
Any pointers?
You shouldn’t need the xprofile field loop.
Use something like this to grab the value directly:
$background_url = xprofile_get_field_data( 'ENTER YOUR XPROFILE FIELD VALUE', bp_get_the_site_member_user_id() );
Thanks for the help r-a-y, I found this solution:
[IN BP_CUSTOM.PHP]:
function custom_xprofile( $field ) {
echo bp_custom_get_member_list_xprofile_data( $field );
}
function bp_custom_get_member_list_xprofile_data( $field ) {
global $site_members_template;
return xprofile_get_field_data( $field, $site_members_template->member->id );
}
[IN CHILD THEME FILE]:
<?php custom_xprofile('Header Image') ?>