Xprofile Fields in Activity Form
-
Does anyone know how to add xprofile fields into the Activity form?
I would like to add a dropdown field, populated with 6 xprofile fields, that when a member s posting they can choose from the dropdown field, and add their choice to the activity they are posting.
I’m almost have it, I’m stuck at this first stage, but the names aren’t showing up:
add_action( 'bp_activity_post_form_options', 'render_pet_activity_fields' ); function render_pet_activity_fields() { echo '<label for="our-pets">Choose pet:</label>'; echo '<select name="our-pets" id="our-pets">'; $args = [ "field" => "137", "user_id" => bp_get_activity_user_id(), ]; $petnames = [bp_profile_field_data($args)]; if (!empty($petnames)) { foreach($petnames1 as $petname) { echo '<option value="' . strip_tags($petname) . '">' . strip_tags($petname) . '</option>'; } } $args = [ "field" => "138", "user_id" => bp_get_activity_user_id(), ]; $petnames2 = [bp_profile_field_data($args)]; if (!empty($petnames2)) { foreach($petnames2 as $petname2) { echo '<option value="' . $petname2 . '">' . $petname2 . '</option>'; } } echo '</select>'; }Using WordPress version 6.94.
- You must be logged in to reply to this topic.