bp_groupblog_validate_blog_signup

Bp_groupblog_validate_blog_signup().

Description

bp_groupblog_validate_blog_signup(); 

Final step before the blog gets created it needs to be validated


Usage

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

Defined (1)

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

/bp-groupblog.php  
  1. function bp_groupblog_validate_blog_signup() { 
  2. global $bp, $wpdb, $current_user, $blogname, $blog_title, $errors; 
  3. global $groupblog_blog_id, $filtered_results; 
  4.  
  5. $group_id = isset( $_COOKIE['bp_new_group_id'] ) ? $_COOKIE['bp_new_group_id'] : bp_get_current_group_id(); 
  6.  
  7. $current_user = wp_get_current_user(); 
  8. if( !is_user_logged_in() ) 
  9. die(); 
  10.  
  11. // Re-validate user info. 
  12. extract($result); 
  13.  
  14. $checks = get_site_option( 'bp_groupblog_blog_defaults_options' ); 
  15.  
  16. if ( $errors->get_error_code() ) { 
  17. $message = ''; 
  18. $message .= $errors->get_error_message('blogname') . '<br />'; 
  19. $message .= __( ' We suggest adjusting the blog address below, in accordance with the following requirements:', 'groupblog' ) . '<br />'; 
  20. if ( $checks['allowunderscores'] != '1' || $checks['allowdashes'] != '1' ) 
  21. $message .= __( ' » Only letters and numbers allowed.', 'groupblog' ) . '<br />'; 
  22. $message .= sprintf( __( ' » Must be at least %s characters.', 'groupblog' ), $checks['minlength'] ) . '<br />' ; 
  23. if ( $checks['allownumeric'] != '1' ) 
  24. $message .= __( ' » Has to contain letters as well.', 'groupblog' ); 
  25. bp_core_add_message( $message, error ); 
  26.  
  27. $redirect_url = bp_is_current_action( 'create' ) ? trailingslashit( bp_get_groups_directory_permalink() . 'create/step/' . bp_action_variable( 1 ) ) : bp_get_group_permalink( groups_get_current_group() ) . '/admin/group-blog/'; 
  28.  
  29. $error_params = array( 
  30. 'create_error' => '4815162342',  
  31. 'invalid_address' => urlencode( $_POST['blogname'] ),  
  32. 'invalid_name' => urlencode( $_POST['blog_title'] ) 
  33. ); 
  34. $redirect_url = add_query_arg( $error_params, $redirect_url ); 
  35. bp_core_redirect( $redirect_url ); 
  36.  
  37.  
  38. $public = (int) $_POST['blog_public']; 
  39.  
  40. groups_update_groupmeta( $group_id, 'groupblog_public', $public); 
  41. groups_update_groupmeta( $group_id, 'groupblog_title', $blog_title); 
  42. groups_update_groupmeta( $group_id, 'groupblog_path', $path); 
  43. groups_update_groupmeta( $group_id, 'groupblog_domain', $domain); 
  44.  
  45. $meta = apply_filters('signup_create_blog_meta', array ('lang_id' => 1, 'public' => $public)); // depreciated 
  46. $meta = apply_filters( "add_signup_meta", $meta ); 
  47.  
  48. $groupblog_blog_id = wpmu_create_blog( $domain, $path, $blog_title, $current_user->ID, $meta, $wpdb->siteid ); 
  49.  
  50. $errors = $filtered_results['errors']; 
  51.  
  52. return true; 
  53.