bp_groupblog_create_screen_save

Bp_groupblog_create_screen_save().

Description

bp_groupblog_create_screen_save(); 

Saves the information from the BP group blog creation step. TO-DO: groupblog-edit-settings is more efficient, rewrite this to be more like that one.


Usage

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

Defined (1)

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

/bp-groupblog.php  
  1. function bp_groupblog_create_screen_save() { 
  2. global $bp; 
  3. global $groupblog_blog_id, $groupblog_create_screen, $filtered_results; 
  4.  
  5. if ( bp_is_action_variable( 'step', 0 ) ) { 
  6. $groupblog_create_screen = true; 
  7. } else { 
  8. $groupblog_create_screen = false; 
  9.  
  10. // Set up some default roles 
  11. $groupblog_default_admin_role = isset( $_POST['default-administrator'] ) ? $_POST['default-administrator'] : BP_GROUPBLOG_DEFAULT_ADMIN_ROLE; 
  12. $groupblog_default_mod_role = isset( $_POST['default-moderator'] ) ? $_POST['default-moderator'] : BP_GROUPBLOG_DEFAULT_MOD_ROLE; 
  13. $groupblog_default_member_role = isset( $_POST['default-member'] ) ? $_POST['default-member'] : BP_GROUPBLOG_DEFAULT_MEMBER_ROLE; 
  14.  
  15. // Set up some other values 
  16. $groupblog_group_id = isset( $_POST['group_id'] ) ? $_POST['group_id'] : bp_get_new_group_id(); 
  17. $silent_add = isset( $_POST['groupblog-silent-add'] ) ? $_POST['groupblog-silent-add'] : ''; 
  18. $page_template_layout = isset( $_POST['page_template_layout'] ) ? $_POST['page_template_layout'] : ''; 
  19. $enable_group_blog = isset( $_POST['groupblog-enable-blog'] ) ? $_POST['groupblog-enable-blog'] : ''; 
  20.  
  21. if ( $_POST['groupblog-create-new'] == 'yes' ) { 
  22. //Create a new blog and assign the blog id to the global $groupblog_blog_id 
  23. if ( !$groupblog_blog_id = bp_groupblog_validate_blog_signup() ) { 
  24. $errors = $filtered_results['errors']; 
  25. bp_core_add_message ( $errors ); 
  26. $group_id = ''; 
  27. } else if ( $_POST['groupblog-create-new'] == 'no' ) { 
  28. // They're using an existing blog, so we try to assign that to $groupblog_blog_id 
  29. if ( !( $groupblog_blog_id = $_POST['groupblog-blogid'] ) ) { 
  30. //They forgot to choose a blog, so send them back and make them do it! 
  31. bp_core_add_message( __( 'Please choose one of your blogs from the drop-down menu.' . $group_id, 'groupblog' ), error ); 
  32. bp_core_redirect( trailingslashit( $bp->loggedin_user->domain . $bp->groups->slug . '/create/step/' . $bp->action_variables[1] ) ); 
  33. } else { 
  34. // They already have a blog associated with the group, we're just saving other settings 
  35. $groupblog_blog_id = groups_get_groupmeta ( $bp->groups->current_group->id, 'groupblog_blog_id' ); 
  36.  
  37. if ( !groupblog_edit_base_settings( $enable_group_blog, $silent_add, $groupblog_default_admin_role, $groupblog_default_mod_role, $groupblog_default_member_role, $page_template_layout, $groupblog_group_id, $groupblog_blog_id ) ) { 
  38. bp_core_add_message( __( 'There was anerrorcreating your group blog, please try again.', 'groupblog' ), error ); 
  39. bp_core_redirect( trailingslashit( $bp->loggedin_user->domain . $bp->groups->slug . '/create/step/' . $bp->action_variables[1] ) );