Search Results for 'group_id'
-
Search Results
-
I am setting up a site where we want to give a standard name to each new group that they can change later in their settings.
That way each new group is say: “Team #1” Where each new team gets the next number.
I tried to put in by using something like:
value="Team #<?php echo bp_new_group_id(); ?>"in the group registration form, but it only returned: Team #0. The group ID hasn’t been created by that step yet…
Any magic to make this possible?
Topic: Solved: Group Stats Problem
Hi,
I have here a code to show in group section -> stats page the stats of the group website with an Stats embedded tool.
But i have a problem, the php work perfectly in group page and i would like to show it on the all users groups on their dashboard like in a widget, i tried with only using the “function display()) but $setting and $setting2 have no value, i don’t know why.
Someone can maybe help me ?
Thanks.
function stats() { if ( bp_is_active( 'groups' ) ) : class Entreprise_Statistiques extends BP_Group_Extension { /** * Your __construct() method will contain configuration options for * your extension, and will pass them to parent::init() */ function __construct() { $args = array( 'slug' => 'entreprise_statistiques', 'name' => 'Statistiques', ); parent::init( $args ); } /** * display() contains the markup that will be displayed on the main * plugin tab */ function display( $group_id = NULL ) { $setting = groups_get_groupmeta( $group_id, 'entreprise_statistiques_setting' ); $setting2 = groups_get_groupmeta( $group_id, 'entreprise_statistiques_setting2' ); $group_id = bp_get_group_id(); ?> <script> StatHatEmbed=new function(){function d(){var a=document.getElementsByTagName("script");return a[a.length-1]}function e(a,b){var d=document.createElement("script"),c="//www.stathat.com/embed/"+a+"/"+b.s1;b.dev&&(c="//localhost:8081/embed/"+a+"/"+b.s1);b.s2&&(c+="/"+b.s2);b.s3&&(c+="/"+b.s3);c+="?w="+b.w+"&h="+b.h+"&tf="+b.tf;b.style&&(c+="&style="+b.style);b.dev&&(c+="&dev=1");b.title&&(c+="&title="+b.title);d.src=c;d.type="text/javascript";document.getElementsByTagName("head")[0].appendChild(d)}function f(a){return[a.s1, a.s2,a.s3,a.w,a.h,a.tf,a.style].join("_")}this.render_graph=function(a){DIV_ID="statd_embed_graph_"+f(a);d().insertAdjacentHTML("AfterEnd","<div id='"+DIV_ID+"' style='display:none'></div>");e("graph",a)};this.render_histogram=function(a){DIV_ID="statd_embed_histogram_"+f(a);d().insertAdjacentHTML("AfterEnd","<div id='"+DIV_ID+"' style='display:none'></div>");e("histogram",a)};this.render_data=function(a){DIV_ID="statd_embed_data_"+f(a);d().insertAdjacentHTML("AfterEnd","<div id='"+DIV_ID+"' style='display:none'></div>"); e("data",a)};this.render_table=function(a){DIV_ID="statd_embed_table_"+f(a);d().insertAdjacentHTML("AfterEnd","<div id='"+DIV_ID+"' style='display:none'></div>");e("table",a)};this.render_text=function(a){DIV_ID=["statd_embed_text",a.s1,a.u].join("_");d().insertAdjacentHTML("AfterEnd","<div id='"+DIV_ID+"' style='display:none'></div>");e("text",a)};this.render=function(a){a.tf||(a.tf="week_compare");a.kind||(a.kind="graph");switch(a.kind){case "graph":this.render_graph(a);break;case "histogram":this.render_histogram(a); break;default:this.render_graph(a)}}}; </script> <div id="stats"> <script>StatHatEmbed.render({s1: '<?php echo($setting); ?>', w: 760, h: 235, tf:'month_compare', style:'fill', title:'<?php echo($setting2); ?>'});</script> </div> <?php if ($setting == NULL) { echo ("Aucun site internet détecté, merci de contacter l'équipe COMMIUM."); } } /** * Création */ function settings_screen( $group_id = NULL ) { $setting = groups_get_groupmeta( $group_id, 'entreprise_statistiques_setting' ); $setting2 = groups_get_groupmeta( $group_id, 'entreprise_statistiques_setting2' ); ?> <input type="text" name="entreprise_statistiques_setting2" id="entreprise_statistiques_setting2" placeholder="Nom d'entreprise"><?php echo esc_attr( $setting2 ) ?></input> <input type="text" name="entreprise_statistiques_setting" id="entreprise_statistiques_setting"placeholder="Code suivi"><?php echo esc_attr( $setting ) ?></input> <?php $settingInfo = $_POST['entreprise_statistiques_setting']; $settingInfo2 = $_POST['entreprise_statistiques_setting2']; } function settings_screen_save( $group_id = NULL ) { $setting = ''; $setting2 = ''; if ( isset( $_POST['entreprise_statistiques_setting']) && isset($_POST['entreprise_statistiques_setting2'] ) ) { $setting = $_POST['entreprise_statistiques_setting']; $setting2 = $_POST['entreprise_statistiques_setting2']; } groups_update_groupmeta( $group_id, 'entreprise_statistiques_setting', $setting ); groups_update_groupmeta( $group_id, 'entreprise_statistiques_setting2', $setting2 ); } } bp_register_group_extension( 'Entreprise_Statistiques' ); endif; // if ( bp_is_active( 'groups' ) ) } echo stats();I wan to display my custom created action activities in activity tab of groups but it is displaying in activity tab which is global. I had tried alot of solution on internet but no one is working.
add_action(‘wp_insert_post’, array($this, ‘bd_custom_bp_record_activity’));
function bd_custom_bp_record_activity() {$gid = bp_get_group_id();
groups_record_activity(array(
‘action’ => apply_filters(‘groups_activity_new_update_action’, sprintf(__(‘%1$s created an event %2$s’, ‘buddypress’), bp_core_get_userlink(get_current_user_id()), ‘‘ . esc_attr(bp_get_group_name()) . ‘‘)),
‘content’ => ‘new post’,
‘type’ => ‘created_event’,
‘item_id’ => $gid,
‘user_id’ => get_current_user_id(),
)
);
}So I found (though I can now track it down) a page with how to add custom fields to a group and it worked (yipee) however during testing we’ve realised that when you add the fields and select ‘Create Group and Continue’ and on the next page select ‘Previous’ your fields are blank. But when you just proceed straight through and don’t ever go back they store. I’m pasting the groups code below if someone knows a hook I can use or similar I’d greatly appreciate it.
function bp_group_meta_init() { function custom_field($meta_key='') { //get current group id and load meta_key value if passed. If not pass it blank return groups_get_groupmeta( bp_get_group_id(), $meta_key) ; } //code if using seperate files require( dirname( __FILE__ ) . '/buddypress-group-meta.php' ); // This function is our custom field's form that is called in create a group and when editing group details function group_header_fields_markup() { global $bp, $wpdb;?> <label for="group-guidelines">Group Guidelines</label> <textarea name="group-guidelines" id="group-guidelines" aria-required="true"></textarea> <br> <label for="group-aims">Group Aims</label> <textarea name="group-aims" id="group-aims" aria-required="true"></textarea> <?php } // This saves the custom group meta – props to Boone for the function // Where $plain_fields = array.. you may add additional fields, eg // $plain_fields = array( // 'field-one', // 'field-two' // ); function group_header_fields_save( $group_id ) { global $bp, $wpdb; $plain_fields = array( 'group-guidelines', 'group-aims' ); foreach( $plain_fields as $field ) { $key = $field; if ( isset( $_POST[$key] ) ) { $value = $_POST[$key]; groups_update_groupmeta( $group_id, $field, $value ); } } } add_filter( 'groups_custom_group_fields_editable', 'group_header_fields_markup' ); add_action( 'groups_group_details_edited', 'group_header_fields_save' ); add_action( 'groups_created_group', 'group_header_fields_save' );