update: in the members type loop it works! in the bp-custom.php no!
my hook
function using_mt_register_member_types() {
bp_register_member_type( 'Problem solver', array(
'labels' => array(
'name' => __( 'Problem solvers', 'using-mt' ),
'singular_name' => __( 'Problem solver', 'using-mt' ),
),
) );
bp_register_member_type( 'Entrepreneur/policy maker', array(
'labels' => array(
'name' => __( 'Entrepreneur/policy maker', 'using-mt' ),
'singular_name' => __( 'Entrepreneur/policy maker', 'using-mt' ),
),
) );
}
add_action( 'bp_init', 'using_mt_register_member_types' );
the field for the registration form:
this driving me crazy!
this could be a problem related to xfield_profile id?
on the table “bp_xprofile_field” the type field got an “id” different from the external key on “bp_xprofile_data” on “field_id”
in casa no idea to how this happen! and if i manual adjust the id the type field disapper from the profile too!
bp_displayed_user_id()
only works in certain contexts – like viewing a member profile.
In other situations, you have to get the member_id differently, perhaps get_current_user_id()
which is a WP function.
thanks a lot but this was already tested with no result!
or better, same result! same id! on the context! i try to give a full vision of my site conf:
on bp-custom on buddypress folder ive this:
function using_mt_register_member_types() {
bp_register_member_type( 'Problem solver', array(
'labels' => array(
'name' => 'Problem solvers',
'singular_name' => 'Problem solver',
),
) );
bp_register_member_type( 'Entrepreneur/policy maker', array(
'labels' => array(
'name' => 'Entrepreneur/policy makers',
'singular_name' => 'Entrepreneur/policy maker',
),
) );
}
add_action( 'bp_init', 'using_mt_register_member_types' );
then in my plugins ive active “Member Type Field for Buddypress XProfile”
and in mine xprofile field ive one setted to select the user type during registration by users. it show my option described above!
then on the same bp_custom file for building a “conditional menu” ive this snippet of code:
function add_break_in_tabs() {
if ( !function_exists( 'bp_get_member_type' ) ) {
require_once ABSPATH . PLUGINDIR . 'buddypress/bp-members/bp-members-functions.php';
}
$user_id=bp_displayed_user_id();
$user_id2=get_current_user_id();
$tipo=bp_get_member_type();
echo $user_id.$user_id2;---->SAME RESULT SHOWED!
echo $tipo;--->NOTHING TO SHOW
var_dump($tipo);---> BOOOL FALSE
....
On the user’s list i can set type for each user.
On registration i can see and select the type.
On Xfield definition ive no option to select but the option showed in the registration form are correct!
thanks a again to any contributor
I spot the problem few second ago! but before it works!
this is the fault code:
add_action( ‘bp_init’, ‘using_mt_register_member_types’ );
should set to
add_action( ‘bp_register_member_types’, ‘using_mt_register_member_types’ );
so bp_init make the mess!
hi hope that can helps