Display the group id PHP ?
-
Hello,
This is my problem, I use ACF PRO to create my own fields on my WordPress theme, for the member profiles part everything works with this code:
<?php /** * BuddyPress - Members Settings ( General ) * * @since 3.0.0 * @version 3.1.0 */ acf_form_head (); $author_id = bp_displayed_user_id(); ?>
<div class="col-lg-6"> <?php acf_form(array( 'id' => 'acf-formA', /* Groupe de champs ID utilisé */ 'field_groups' => array('663'), //CHANGE ID IN LIVE /* Quelle est la function meta utiliser en $ sur ID auteur ? */ 'post_id' => 'user_'.$author_id, /* Quel est le nom sur le bouton du button de sauvegarde */ 'submit_value' => __("SAUVEGARDER", 'acf'), /* Le message que je retourne en cas de réussite sur l'infobox bootstrap */ 'updated_message' => __("Mise à jour réalisée", 'acf'), /* Button de submit de formulaire */ 'html_submit_button' => '<div class="text-center"><input name="updateuser1" type="submit" id="updateuser1" class="btn-style1" value="%s" /></div>', /* Le spinner de chargement */ 'html_submit_spinner' => '<span class="acf-spinner"></span>', 'form' => true, 'return' => '' )); add_action('acf/save_post', 'my_acf_save_post', 20); ?> </div>
So far no problem to display then on the member’s profile page the information of the ACF field.
My Problem:
On the other hand, on the Groups part I can’t find how to attach the field to the ID group, that’s what I tried.In my edit-details.php (in group),My field works, I enter test in my acf form
it comes out in the echo “test” but on all the groups, I can’t associate this field with the group id.<?php /** * BP Nouveau Group's edit details template. * * @since 3.0.0 * @version 3.1.0 * @version 4.0.0 Removed 'Notify group members' checkbox in favor of hooked callback. */ acf_form_head (); $group_id = bp_displayed_user_id(); $group = new BP_Groups_Group( $group_id ); ?>
<?php echo get_field('test_group', 'group_'. $group_id); ?>
<?php acf_form(array( 'id' => 'acf-formA', /* Groupe de champs ID utilisé */ 'field_groups' => array('714'), //CHANGE ID IN LIVE /* Quelle est la function meta utiliser en $ sur ID auteur ? */ 'post_id' => 'group_'.$group_id, /* Quel est le nom sur le bouton du button de sauvegarde */ 'submit_value' => __("SAUVEGARDER", 'acf'), /* Le message que je retourne en cas de réussite sur l'infobox bootstrap */ 'updated_message' => __("Mise à jour réalisée", 'acf'), /* Button de submit de formulaire */ 'html_submit_button' => '<div class="text-center"><input name="updateuser1" type="submit" id="updateuser1" class="btn-style1" value="%s" /></div>', /* Le spinner de chargement */ 'html_submit_spinner' => '<span class="acf-spinner"></span>', 'form' => true, 'return' => '' )); add_action('acf/save_post', 'my_acf_save_post', 20); ?>
Thanks for your help !
demo : https://cryodev.fr/branch/build/alpha/groupes/le-groupe-a-demo/
- You must be logged in to reply to this topic.