groupblog_edit_settings

Groupblog_edit_settings().

Description

groupblog_edit_settings(); 

Save the blog-settings accessible only by the group admin or mod.

Since version 1.6, this function has been called directly by BP_Groupblog_Extension::edit_screen_save()


Usage

  1. if ( !function_exists( 'groupblog_edit_settings' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'bp-groupblog/bp-groupblog.php'; 
  3.  
  4.  
  5. // NOTICE! Understand what this does before running. 
  6. $result = groupblog_edit_settings(); 
  7.  

Defined (1)

The function is defined in the following location(s).

/bp-groupblog.php  
  1. function groupblog_edit_settings() { 
  2. global $bp, $groupblog_blog_id, $errors, $filtered_results; 
  3.  
  4. $group_id = isset( $_POST['groupblog-group-id'] ) ? $_POST['groupblog-group-id'] : bp_get_current_group_id(); 
  5.  
  6. if ( !bp_groupblog_blog_exists( $group_id ) ) { 
  7. if ( isset( $_POST['groupblog-enable-blog'] ) ) { 
  8. if ( $_POST['groupblog-create-new'] == 'yes' ) { 
  9. //Create a new blog and assign the blog id to the global $groupblog_blog_id 
  10. if ( !bp_groupblog_validate_blog_signup() ) { 
  11. $errors = $filtered_results['errors']; 
  12. bp_core_add_message ( $errors ); 
  13. $group_id = ''; 
  14. } else if ( $_POST['groupblog-create-new'] == 'no' ) { 
  15. // They're using an existing blog, so we try to assign that to $groupblog_blog_id 
  16. if ( !( $groupblog_blog_id = $_POST['groupblog-blogid'] ) ) { 
  17. //They forgot to choose a blog, so send them back and make them do it! 
  18. bp_core_add_message( __( 'Please choose one of your blogs from the drop-down menu.' . $group_id, 'groupblog' ), error ); 
  19. if ( bp_is_action_variable( 'step', 0 ) ) { 
  20. bp_core_redirect( trailingslashit( $bp->loggedin_user->domain . $bp->groups->slug . '/create/step/' . $bp->action_variables[1] ) ); 
  21. } else { 
  22. bp_core_redirect( trailingslashit( $bp->root_domain . '/' . $bp->current_component . '/' . $bp->current_item . '/admin/group-blog' ) ); 
  23. } else { 
  24. // They already have a blog associated with the group, we're just saving other settings 
  25. $groupblog_blog_id = groups_get_groupmeta ( $bp->groups->current_group->id, 'groupblog_blog_id' ); 
  26.  
  27. // Get the necessary settings out of the $_POST global so that we can use them to set up 
  28. // the blog 
  29. $settings = array( 
  30. 'groupblog-enable-blog' => '',  
  31. 'groupblog-silent-add' => '',  
  32. 'default-administrator' => '',  
  33. 'default-moderator' => '',  
  34. 'default-member' => '',  
  35. 'page_template_layout' => '' 
  36. ); 
  37.  
  38. foreach( $settings as $setting => $val ) { 
  39. if ( isset( $_POST[$setting] ) ) { 
  40. $settings[$setting] = $_POST[$setting]; 
  41.  
  42. if ( !groupblog_edit_base_settings( $settings['groupblog-enable-blog'], $settings['groupblog-silent-add'], $settings['default-administrator'], $settings['default-moderator'], $settings['default-member'], $settings['page_template_layout'], $group_id, $groupblog_blog_id ) ) { 
  43. bp_core_add_message( __( 'There was anerrorcreating your group blog, please try again.', 'groupblog' ), error ); 
  44. } else { 
  45. bp_core_add_message( __( 'Group details were successfully updated.', 'groupblog' ) ); 
  46.  
  47. do_action( 'groupblog_details_edited', $bp->groups->current_group->id ); 
  48.  
  49. //bp_core_redirect( $bp->root_domain . '/' . $bp->current_component . '/' . $bp->current_item . '/admin/group-blog' ); 
  50.