Skip to:
Content
Pages
Categories
Search
Top
Bottom

Fix for subdomains

  • Avatar of Lemmy
    Lemmy
    Participant

    @lemmyc

    I have a patch which seems to fix the problem with subdomain installs. (ie. group blog was not created, posts from blog #1 were displayed instead.)

    Hmm, no way to attach the patch file?
    Here are the relevant bits in bp-groupblog.php. Replace your functions. Please let me know if it works for you.

    `
    function bp_groupblog_validate_blog_signup() {
    global $bp, $wpdb, $current_user, $blogname, $blog_title, $errors;
    global $groupblog_blog_id;

    $group_id = $_COOKIE;

    require_once( ABSPATH . WPINC . ‘/registration.php’ );

    $current_user = wp_get_current_user();
    if( !is_user_logged_in() )
    die();

    // Re-validate user info.
    $result = bp_groupblog_validate_blog_form();
    extract($result);

    $checks = get_site_option(‘bp_groupblog_blog_defaults_options’);

    if ( $errors->get_error_code() ) {
    $message .= $errors->get_error_message(‘blogname’);
    $message .= __( ‘ However, you may continue with the blog address as listed below.’, ‘groupblog’ );
    $message .= __( ‘ We suggest adjusting the group name in group details following these requirements.’, ‘groupblog’ );
    if ( $checks != ‘1’ || $checks != ‘1’ )
    $message .= __( ‘ » Only letters and numbers allowed.’, ‘groupblog’ );
    $message .= sprintf( __( ‘ » Must be at least %s characters.’, ‘groupblog’ ), $checks );
    if ( $checks != ‘1’ )
    $message .= __( ‘ » Has to contain letters as well.’, ‘groupblog’ );
    bp_core_add_message( $message, ‘error’ );

    //Hello Lost fan!
    if ( $bp->action_variables[0] == ‘step’ ) {
    bp_core_redirect( $bp->loggedin_user->domain . $bp->groups->slug . ‘/create/step/’ . $bp->action_variables[1] . ‘/?create_error=4815162342′ );
    } else {
    bp_core_redirect( $bp->root_domain . ‘/’ . $bp->current_component . ‘/’ . $bp->current_item . ‘/admin/group-blog/?create_error=4815162342′ );
    }
    }

    $public = (int) $_POST;

    if ( $bp->action_variables[0] == ‘step’ ) {
    groups_update_groupmeta( $group_id, ‘groupblog_public’, $public);
    groups_update_groupmeta( $group_id, ‘groupblog_title’, $blog_title);
    groups_update_groupmeta( $group_id, ‘groupblog_path’, $path);
    groups_update_groupmeta( $group_id, ‘groupblog_domain’, $domain);

    } else {
    $meta = apply_filters(‘signup_create_blog_meta’, array (‘lang_id’ => 1, ‘public’ => $public)); // depreciated
    $meta = apply_filters( “add_signup_meta”, $meta );

    $groupblog_blog_id = wpmu_create_blog( $domain, $path, $blog_title, $current_user->id, $meta, $wpdb->siteid );
    }

    $errors = $filtered_results;

    return true;

    }

    /**
    * bp_groupblog_create_blog( $group_id )
    *
    * We know everything is final and now are ready to create the blog at group complete stage.
    */
    function bp_groupblog_create_blog( $group_id ) {
    global $wpdb, $domain;

    if ( ( groups_get_groupmeta ( $group_id, ‘groupblog_enable_blog’ ) != 1 ) || ( groups_get_groupmeta ( $group_id, ‘groupblog_blog_id’ ) != ” ) )
    return;

    $current_user = wp_get_current_user();
    if( !is_user_logged_in() )
    die();

    $public = groups_get_groupmeta( $group_id, ‘groupblog_public’);
    $blog_title = groups_get_groupmeta( $group_id, ‘groupblog_title’);
    $path = groups_get_groupmeta( $group_id, ‘groupblog_path’);
    $domain = groups_get_groupmeta( $group_id, ‘groupblog_domain’);

    $meta = apply_filters(‘signup_create_blog_meta’, array (‘lang_id’ => 1, ‘public’ => $public)); // depreciated
    $meta = apply_filters( “add_signup_meta”, $meta );

    $groupblog_blog_id = wpmu_create_blog( $domain, $path, $blog_title, $current_user->id, $meta, $wpdb->siteid );

    groups_update_groupmeta ( $group_id, ‘groupblog_blog_id’, $groupblog_blog_id );
    groups_update_groupmeta( $group_id, ‘groupblog_public’, ”);
    groups_update_groupmeta( $group_id, ‘groupblog_title’, ”);
    groups_update_groupmeta( $group_id, ‘groupblog_path’, ”);
    groups_update_groupmeta( $group_id, ‘groupblog_domain’, ”);

    }

    function bp_groupblog_show_blog_form( $blogname = ”, $blog_title = ”, $errors = ” ) {
    global $bp, $groupblog_create_screen, $current_site;
    ?>


    get_error_message(‘blog_title’) ) { ?>

    blogname; ?>

    <input name="blog_title" type="hidden" id="blog_title" value="blogname; ?>” />


    get_error_message(‘blogname’) ) { ?>

    <?php }
    $checks = get_site_option(‘bp_groupblog_blog_defaults_options’);

    $baddies = array ();
    if ( $checks != ‘1’ )
    $baddies[] = ‘-‘;
    if ( $checks != ‘1’ )
    $baddies[] = ‘_';

    $blog_address = str_replace ( $baddies, ”, $bp->groups->current_group->slug );
    ?>

    siteurl; ?>

    <input name="blogname" type="hidden" id="blogname" value="siteurl; ?>” maxlength=”50″ />

    groups->current_group->status == ‘public’ ? $group_public = ‘1’ : $group_public = ‘0’; ?>
    <input type="hidden" id="blog_public" name="blog_public" value="” />
    <input type="hidden" id="groupblog_create_screen" name="groupblog_create_screen" value="” />

    <input disabled=”true” type=”radio” value=”no” name=”groupblog-create-new” />  
    <select disabled=”true” name=”groupblog-blogid” id=”groupblog-blogid”>

    <?php
    $user_blogs = get_blogs_of_user( get_current_user_id() );
    //print_r ($user_blogs);
    foreach ($user_blogs AS $user_blog) {
    if ( !get_groupblog_group_id( $user_blog->userblog_id ) ) { ?>
    <option value="userblog_id; ?>”>blogname; ?>
    <?php }
    } ?>

    <input disabled=”true” type=”radio” value=”yes” name=”groupblog-create-new” checked=”checked” /> 


    • get_error_message(‘blog_title’) ) { ?>

      groups->current_group->name; ?>
      <input name="blog_title" type="hidden" id="blog_title" value="groups->current_group->name; ?>” />


    • get_error_message(‘blogname’) ) { ?>

      <?php }
      $checks = get_site_option(‘bp_groupblog_blog_defaults_options’);

      $baddies = array ();
      if ( $checks != ‘1’ )
      $baddies[] = ‘-‘;
      if ( $checks != ‘1’ )
      $baddies[] = ‘_';

      $blog_address = str_replace ( $baddies, ”, $bp->groups->current_group->slug );

      /*
      * If we’re re-directing from bp_groupblog_validate_blog_signup(), it means that there was a problem
      * creating the blog either because the name already exists, or it doesn’t have enough characters, or
      * because it only contains numbers.
      */
      if ( isset ( $_GET ) ) {
      $blog_address .= ‘blog';
      }
      ?>

      domain . $current_site->path ?>

      domain . $current_site->path . $blog_address ?>

      <input name="blogname" type="hidden" id="blogname" value="” maxlength=”50″ />

    groups->current_group->status == ‘public’ ? $group_public = ‘1’ : $group_public = ‘0’; ?>
    <input type="hidden" id="blog_public" name="blog_public" value="” />
    <input type="hidden" id="groupblog_create_screen" name="groupblog_create_screen" value="” />

    <?php
    do_action(‘signup_blogform’, $errors);
    }
    `

Viewing 3 replies - 1 through 3 (of 3 total)
  • Avatar of Lemmy
    Lemmy
    Participant

    @lemmyc

    Avatar of Lemmy
    Lemmy
    Participant

    @lemmyc

    I had a problem with the admin bar not showing but that’s just because I have Activities switched off. The same error occurs in subdirectory installs.

    I just commented out the include( ‘groupblog/inc/activity.php’ ); lines for a quick fix. Maybe there’s a better solution?

    I was getting the following error:
    Fatal error: Call to undefined function bp_has_activities() in …./wp-content/plugins/bp-groupblog/groupblog/inc/activity.php on line 9

    Avatar of Mariusooms
    Mariusooms
    Participant

    @mariusooms

    Thanks Lemmy…the fix is in the latest release! I’ll have to take a look at that activity component in case it is turned off. Thanks for pointing that out.

Viewing 3 replies - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.