Unable to modify BuddyPress with CSS or php

  • aobuchowska

    #8035

    Hello,

    I would like to fix the appearance of the Buddypress pages as well as change some of its functionality. I was able to do this with Graphene using the custom CSS code and by creating a child functions.php file. However, when I try to do this with GM Neo I don’t see any change. I know the files I put in wp-content/uploads/gmneo-custom folder work because other aspects of the website (for example formidable pro plugin etc) do get modified by the files. Could you please tell me, if possible, what I can do to fix? I would greatly appreciate it.

    Admin

    Syahir Hakim

    #40147

    Can you provide more details on what exactly were you trying to change, what code you added and where, as well as the URL to the concerned pages?

    aobuchowska

    #40151

    Hello Syahir,

    I am trying to post a reply but it does not get posted. Maybe the length of the message is too long.

    aobuchowska

    #40156

    Hello Syahir,

    Thank you very much for your response. I am trying to change several things. First, I am trying remove the option for users to create public teams in buddypress. Also, I am would like to remove the members directory search by name. The url to one of the BuddyPress pages is here. Please note that you need to be logged in to create a team. In addition, I am trying to implement some changes to a plugin called “Whisper comments reloaded”. In this plugin I am not able to select the post author. The url to one of the pages is here.

    As for BuddyPress CSS I would like to implement the CSS of Buddypress pages or my own CSS. Is it possible to insert some code from the BuddyPress plugin into the the themes files?

    I also have some code to put in a child comments.php file that modifies graphene’s comment count. I tried to include the code in this message but the reply did not get posted.

    Agnes

    aobuchowska

    #40157

    The below code was put in child theme functions.php and works well in Graphene but not in mobile.

    <?php

    /**************************** PART 1 ****************************/

    /**
    * Remove the members scope filter to deselect friends tab.
    */
    function remove_members_search_cookies() {
    setcookie('bp-members-scope', null, 0, '/');
    }

    add_action('init', 'remove_members_search_cookies');

    /**
    * Prevent all members appearing in directory
    */
    function set_ajax_querystring($query_string, $object, $object_filter, $object_scope, $object_page, $object_search_terms, $object_extras) {
    if (!empty($object) && $object == 'members' && empty($_POST['bp_profile_search'])) {
    $user_id = (bp_displayed_user_id()) ? bp_displayed_user_id() : bp_loggedin_user_id();
    if (empty($user_id))
    $user_id = -1;
    if (!empty($query_string))
    $query_string .= '&';
    $query_string .= 'user_id=' . $user_id;
    }
    return $query_string;
    }

    add_filter('bp_legacy_theme_ajax_querystring','set_ajax_querystring', 99, 7);

    /**
    * Remove search summary. Part of "BP Profile Search" plugin.
    */
    function profile_search_cookie() {
    if (function_exists('bps_cookies')) {
    global $bps_results;
    if (isset($_POST['bp_profile_search'])) {
    $bps_results = bps_search($_POST);
    $bps_results['validated'] = true;
    setcookie('bp-profile-search', serialize($_POST), 0, COOKIEPATH);
    } else if (isset($_COOKIE['bp-profile-search'])) {
    if (defined ('DOING_AJAX'))
    $bps_results = bps_search (unserialize(stripslashes($_COOKIE['bp-profile-search'])));
    else
    setcookie('bp-profile-search', '', 0, COOKIEPATH);
    }
    }
    }

    remove_action('wp_loaded', 'bps_cookies');
    add_action('wp_loaded', 'profile_search_cookie', 99);

    /**************************** PART 3 ****************************/

    /**
    * Set new group status to private if currently public
    */
    function new_group_private_status($status) {
    if ('public' == $status)
    $status = 'private';
    return $status;
    }

    add_filter('bp_get_new_group_status', 'new_group_private_status', 99, 1);

    /**************************** PART 4 ****************************/

    /**
    * Remove public access options from BuddyPress Docs plugin.
    */
    function get_access_options($options, $settings_field, $doc_id, $group_id) {
    foreach ($options as $key => $option) {
    if ($option['name'] != 'creator' && $option['name'] != 'admins-mods' && $option['name'] != 'group-members')
    unset($options[$key]);
    }
    return $options;
    }

    add_filter('bp_docs_get_access_options', 'get_access_options');

    /**************************** PART 6 ****************************/

    /**
    * Filter message details of comment notification email
    */
    function remove_details_notify_message($notify_message, $comment_id) {
    $lines = explode("rn", $notify_message);
    $output = array();
    foreach ($lines as $line) {
    if (strpos($line, 'Author :') === 0)
    $output[] = trim(preg_replace('/s*([^)]*)/', '', $line));
    else if (strpos($line, 'E-mail :') === 0)
    continue;
    else if (strpos($line, 'Whois :') === 0)
    continue;
    else if (strpos($line, 'Website:') === 0)
    $output[] = trim(preg_replace('/s*([^)]*)/', '', $line));
    else $output[] = $line;
    }
    return implode("rn", $output);
    }

    add_filter('comment_notification_text', 'remove_details_notify_message', 99, 2);

    /**
    * Filter header details of comment notification email
    */
    function remove_details_message_headers($message_headers, $comment_id) {
    $lines = explode("n", $message_headers);
    $output = array();
    foreach ($lines as $line) {
    if (strpos($line, 'Reply-To:') === 0)
    continue;
    else $output[] = $line;
    }
    return implode("n", $output);
    }

    add_filter('comment_notification_headers', 'remove_details_message_headers', 99, 2);

    /**************************** PART 7 ****************************/

    /**
    * Override function for gmneo_get_comment_count()
    * Only used when all of these conditions are true:
    * 1. User logged in
    * 2. "Whisper Comments Modified" plugin on
    * 3. Plugin setting "Activate" on
    */
    if (!function_exists('gmneo_get_comment_count') && is_user_logged_in()) {

    $whisper_comment_options = get_option('whisper_comment_options');
    $show_private_messages = !empty($whisper_comment_options['whisper_on']);

    if (class_exists('WhisperComment') && $show_private_messages) {

    define('OVERRIDE_gmneo_GET_COMMENT_COUNT', true);

    /**
    * Adds the functionality to count comments by type, eg. comments, pingbacks, tracbacks. Return the number of comments, but do not print them.
    * Based on the code at WPCanyon (http://wpcanyon.com/tipsandtricks/get-separate-count-for-comments-trackbacks-and-pingbacks-in-wordpress/)
    *
    * In gmneo version 1.3 the $noneText param has been removed
    *
    * @package gmneo
    * @since gmneo 1.3
    *
    * Modified to support the "Whisper Comment Modifed" plugin
    */
    function gmneo_get_comment_count( $type = 'comments', $only_approved_comments = true, $top_level = false ){
    $current_user = wp_get_current_user();
    if (1 == $current_user->ID)
    $whisper_sql = 'comment_type LIKE "whisper%"'; // Admin sees all whispers
    else {
    $whisper_sql = '( ( comment_type LIKE "whisper%" AND user_id = "' . $current_user->ID . '" )'; // Whispers from non-admin user
    $whisper_sql .= ' OR ( comment_type = "whisper:' . $current_user->ID . '" ) )'; // Whispers to non-admin user
    }

    if ( $type == 'comments' )
    $type_sql = 'comment_type = ""';
    elseif ( $type == 'pings' )
    $type_sql = '( comment_type != "" AND comment_type NOT LIKE "whisper%" )';
    elseif ( $type == 'trackbacks' )
    $type_sql = 'comment_type = "trackback"';
    elseif ( $type == 'pingbacks' )
    $type_sql = 'comment_type = "pingback"';
    elseif ( $type == 'whispers' )
    $type_sql = $whisper_sql;

    $type_sql = apply_filters( 'gmneo_comments_typesql', $type_sql, $type );
    $approved_sql = $only_approved_comments ? ' AND comment_approved="1"' : '';
    $top_level_sql = ( $top_level ) ? ' AND comment_parent="0" ' : '';

    global $wpdb;
    $result = $wpdb->get_var('
    SELECT COUNT(comment_ID)
    FROM ' . $wpdb->comments . '
    WHERE ' . $type_sql . $approved_sql . $top_level_sql . '
    AND comment_post_ID= ' . get_the_ID() );
    return $result;
    }
    }
    }

    /**************************** PART 8 ****************************/

    /**
    * Set new group status to hidden
    */
    function set_new_group_status_hidden($group_id, $member, $group) {
    $group->status = 'hidden';
    $group->save();
    }

    add_action('groups_create_group', 'set_new_group_status_hidden', 10, 3);

    // END

    <?php
    /* Only show comments depending on the theme setting */
    if ( ! gmneo_should_show_comments() ) :
    return;
    endif;
    ?>

    <?php if ( post_password_required() && ( comments_open() || have_comments() ) ) : ?>
    <div id="comments">
    <p class="nopassword"><?php _e( 'This post is password protected. Enter the password to view any comments.', 'gmneo' ); ?></p>

    <?php do_action( 'gmneo_protected_comment' ); ?>
    </div><!-- #comments -->
    <?php
    /* Stop the rest of comments.php from being processed,
    * but don't kill the script entirely -- we still have
    * to fully load the template.
    */
    return;
    endif;
    ?>

    <?php do_action( 'gmneo_before_comment_template' ); ?>

    <?php /* Lists all the comments for the current post */ ?>
    <?php if ( have_comments() ) : ?>

    <?php /* Get the comments and pings count */
    global $gmneo_tabbed_comment;
    $comments_num = gmneo_get_comment_count();
    // to also show comments awaiting approval
    $allcomments_num = gmneo_get_comment_count( 'comments', false );
    $pings_num = gmneo_get_comment_count( 'pings' );
    $whispers_num = defined('OVERRIDE_gmneo_GET_COMMENT_COUNT') ? gmneo_get_comment_count( 'whispers' ) : 0;

    if ( $comments_num )
    $comment_count = sprintf( _n( '%s comment', '%s comments', $comments_num, 'gmneo' ), number_format_i18n( $comments_num ) );
    if ( $pings_num )
    $ping_count = sprintf( _n( '%s ping', '%s pings', $pings_num, 'gmneo' ), number_format_i18n( $pings_num ) );
    if ( $whispers_num )
    $whispers_count = sprintf( _n( '%s private message', '%s private messages', $whispers_num, 'gmneo' ), number_format_i18n( $whispers_num ) );

    $gmneo_tabbed_comment = ( $comments_num && $pings_num && $whispers_num ) ? true : false;

    $class = 'clearfix';
    if ( ! $comments_num ) $class .= ' no-comment';
    if ( ! $pings_num ) $class .= ' no-ping';
    if ( ! $whispers_num ) $class .= ' no-whisper';

    global $is_paginated;
    $is_paginated = get_option( 'page_comments' );
    ?>

    <div id="comments" class="<?php echo $class; ?>">
    <?php if ( $comments_num ) : ?>
    <h4 class="comments gutter-left current"><?php if ($gmneo_tabbed_comment) {echo '<a href="#">'.$comment_count.'</a>';} else {echo $comment_count;}?></h4>
    <?php endif; ?>
    <?php if ( $pings_num ) : ?>
    <h4 class="pings gutter-left"><?php if ($gmneo_tabbed_comment) {echo '<a href="#">'.$ping_count.'</a>';} else {echo $ping_count;}?></h4>
    <?php endif; ?>
    <?php if ( $whispers_num ) : ?>
    <h4 class="whispers gutter-left" title="Click to toggle messages"><?php if ($gmneo_tabbed_comment) {echo '<a href="#">'.$whispers_count.'</a>';} else {echo $whispers_count;}?></h4>
    <?php endif; ?>

    <?php if ( ( ( $is_paginated && get_option( 'comments_per_page' ) > 3 ) || ! $is_paginated ) && ( $comments_num > 3 || $pings_num > 6 ) ) : ?>
    <p class="comment-form-jump"><a href="#respond"><?php _e( 'Skip to comment form', 'gmneo' ); ?></a> &darr;</p>
    <?php endif; ?>

    <?php do_action( 'gmneo_before_comments' ); ?>

    <?php if ( $comments_num || $allcomments_num || $whispers_num ) : ?>
    <div class="comments-list-wrapper">
    <ol class="clearfix" id="comments_list">
    <?php
    /* Loop through and list the comments. Tell wp_list_comments()
    * to use gmneo_comment() to format the comments.
    * If you want to overload this in a child theme then you can
    * define gmneo_comment() and that will be used instead.
    * See gmneo_comment() in functions.php for more.
    */
    $args = array( 'callback' => 'gmneo_comment', 'style' => 'ol', 'type' => 'comment' );
    wp_list_comments( apply_filters( 'gmneo_comments_list_args', $args ) ); ?>
    </ol>

    <?php gmneo_comments_nav(); ?>
    </div>
    <?php endif; ?>

    <?php if ( $pings_num ) : ?>
    <ol class="clearfix<?php if (!$comments_num) echo ' display-block'; ?>" id="pings_list">
    <?php
    /* Loop through and list the pings. Use the same callback function as
    * listing comments above, gmneo_comment() to format the pings.
    */
    $args = array( 'callback' => 'gmneo_comment', 'style' => 'ol', 'type' => 'pings', 'per_page' => 0 );
    wp_list_comments( apply_filters( 'gmneo_pings_list_args', $args ) ); ?>
    </ol>
    <?php endif; ?>

    <?php do_action( 'gmneo_after_comments' ); ?>
    </div>
    <?php endif; // Ends the comment listing ?>

    <?php /* Display comments disabled message if there's already comments, but commenting is disabled */ ?>
    <?php if ( ! comments_open() && have_comments() ) : ?>
    <div id="respond">
    <h3 id="reply-title"><?php _e( 'Comments have been disabled.', 'gmneo' ); ?></h3>
    <?php do_action( 'gmneo_comments_disabled' ); ?>
    </div>
    <?php endif; ?>

    <?php /* Display the comment form if comment is open */ ?>
    <?php if ( comments_open() ) : ?>

    <div id="comment-form-wrap" class="clearfix">
    <?php do_action( 'gmneo_before_commentform' );

    /* Get the comment form. */

    $allowedtags = '';
    if ( ! $gmneo_settings['hide_allowedtags'] ){
    $allowedtags .= '<p class="form-allowed-tags">';
    $allowedtags .= sprintf( __( 'You may use these <abbr title="HyperText Markup Language">HTML</abbr> tags and attributes: %s', 'gmneo' ), '<code>' . allowed_tags() . '</code>' );
    $allowedtags .= '</p>';
    }

    $args = array(
    'comment_notes_after' => apply_filters( 'gmneo_comment_allowedtags', $allowedtags ),
    'id_form' => 'commentform',
    'label_submit' => __( 'Submit Comment', 'gmneo' ),
    );
    comment_form( apply_filters( 'gmneo_comment_form_args', $args ) );

    do_action( 'gmneo_after_commentform' ); ?>
    </div>

    <?php endif; // Ends the comment status ?>

    I apologize for the length of this message.

    Agnes

    I apologize for the length of this message.

    Agnes

    aobuchowska

    #40158

    Sorry, I forgot to mention that the second code in the above message was put in a child comments.php file in graphene.

    Mod

    Kenneth John Odle

    #40159

    For that amount of code, please use pastebin.com. Thank you.

Viewing 7 posts - 1 through 7 (of 7 total)

You must be logged in to reply to this topic.