Skip to:
Content
Pages
Categories
Search
Top
Bottom

Reply To: Find the new field_ name/id in the database?

@danbp

Participant

hi @tipsy,

You didn’t explain what you wanted to achieve , so it’s a bit difficult to give a precise answer… but glad you got it ! 😉

Your solution, a bit simplier

$field = xprofile_get_field_data( '2', $user_id ); 
echo $field;

Here two examples. The first allows to publish a video on the profile and works only if you’re in the member loop. The second does the same thing, but outside of the loop and need that you add an action hook to your template where the vid should play. When outside of the loop, you need always a user_id

function set_video_field( $field_value ) {
	$bp_this_field_name = bp_get_the_profile_field_name();
	// field name (case sensitive)
	if( $bp_this_field_name == 'Video' ) {
		$field_value = strip_tags( $field_value );
		$field_value = '<iframe width="420" height="315" src="http://www.youtube.com/embed/'.$field_value.'" frameborder="0" allowfullscreen></iframe>';
	}
	return $field_value;
}
add_filter( 'bp_get_the_profile_field_value','set_video_field');

For outside the loop. Add do_action( 'myfield' ); into a custom template.

function bpfr_field( $custom_field ) {
	global $bp;
	
	// is xprofile component active ?
	if ( bp_is_active( 'xprofile' ) )
	
	// fetch the user_id
	$current_user = wp_get_current_user();
	$current_user_id = $current_user->ID;
	
	// fetch the data
	$custom_field = xprofile_get_field_data('24', $current_user_id); // the field ID

	$output = '<iframe width="420" height="315" src="http://www.youtube.com/embed/'.$custom_field.'" frameborder="0" allowfullscreen></iframe>';
	
	// show the data
	if ( is_user_logged_in() && !empty( $custom_field ) ) :
		echo '<div class="authorinfo">'. $output . '</div>';
	endif;
}
add_action( 'myfield', 'bpfr_field', 1 );

May this help ?

Skip to toolbar