Skip to:
Content
Pages
Categories
Search
Top
Bottom

Reply To: Access to BP functions in external code via wp-load

@danbp

Participant

I guess you do it wrong.

If you need an extra page, the usual method is to copy the page.php file of your theme into your child-theme and make your modification in that file.

See WP and BP codex for this.

To show an xprofile value somewhere, and specially outside of the profile loop, you just write a function for that and add it to your child-theme functions.php

This forum is full of examples of how you can do this.

As example, here’s a snippet to fetch a profile field with the ID 42

function bpfr_field( $custom_field ) {
	global $bp;
	
	// is xprofile component active ?
	if ( bp_is_active( 'xprofile' ) )
	
	// fetch the user_id. Mandatory.
	$current_user = wp_get_current_user();
	$current_user_id = $current_user->ID;
	
	// fetch the data
	$custom_field = xprofile_get_field_data('42', $current_user_id); // 42 is a field ID
	
	// show the data
	echo '<div class="authorinfo">'. $custom_field .'</div>';
	
}
add_action( 'myfield', 'bpfr_field', 1 );

And at the appropriate place on your template, you add an action hook

<?php do_action( 'myfield'); ?>

No need to reinvent the wheel or to call wp twice. 😉

Skip to toolbar