Skip to:
Content
Pages
Categories
Search
Top
Bottom

Forum Replies Created

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

  • aljo1985
    Participant

    @aljo1985

    Okay so I realised that it would only send the activity to stream when you have the email option checked. I also noticed that upon doing that you post 2 pieces of information into the database that are exactly the same.. Well they are not structured the same but the information holds the same data.

    This is inside bp_groups_groupmeta and bp_activity
    So I have optimized my code to remove duplicate data, well just removed it from posting into groupsmeta really, as it doesn’t need to be in there… Maybe you can optimize your code to post the action in activity only and read from there, rather than have it posted in both. The system is great, don’t get me wrong I am just making suggestions.

    So I have removed one of your functions on remove action and copied it into my own function with edits to that function. I have added 2 extra fields, drop down boxs to be exact.

    Here is my code with a lot of comments as I was trying out many different things, then decided I don’t want it to do that lol. EDIT

    <?php
    // Add custom group fields.
    // Removed the default add activity stream. file /public_html/wp-content/plugins/buddypress/bp-groups/bp-groups-activity.php for reference.
    remove_action( 'groups_details_updated', 'bp_groups_group_details_updated_add_activity' );
    // On group update.
    add_action( 'groups_details_updated', 'group_details_update', 10, 3 );
    // Updated group details.
    // Updated group details.
    function group_details_update( $group_id, $old_group, $notify_members ) {
    	global $bp, $wpdb;
    	// Custom fields.
    	$plain_fields = array(
    		'server',
    		'country'
    		//'activity'
    	);
    	foreach( $plain_fields as $field ) {
    		$key = 'group-' . $field;
    		$metakey = 'h1z1_' . $field;
    		if ( isset( $_POST[$key] ) ) {
    			$value = $_POST[$key];
    			
    			// Do they want the update notification posted on their activity stream?
    			/*if ($value == '1')
    				$post_activity = true;
    			*/
    			//Make sure they selected an item from the required dropdown boxs.
    			if ($value == 'null')
    				return bp_core_add_message( __( 'There was an error updating group details. Please try again.', 'buddypress' ), 'error' );
    			else {
    				// changed1 is empty by default, not declared. If empty, get groupmeta.
    				if (empty($changed))
    					$changed = groups_get_groupmeta( $group_id, $metakey );
    				//if groupmeta(old value) == posted value changed is empty again, so we can check the next custom field to see if that also has the same old value.
    				if ($changed == $value)
    					$changed = '';
    				else
    					groups_update_groupmeta( $group_id, $metakey, $value );
    			}
     		}
    	}
    	// Optional removed checkbox for now.. Might use later
    	/*if ($post_activity == false)
    		return false;
    	*/
    	// Taken from /public_html/wp-content/plugins/buddypress/bp-groups/bp-groups-activity.php
    	// We removed the email notification check so that it will post an activity stream regardless.
    	// Bail if Activity is not active.
    	if ( ! bp_is_active( 'activity' ) )
    		return false;
    
    	if ( ! isset( $old_group->name ) || ! isset( $old_group->description ) )
    		return false;
    
    	// If the admin has opted not to notify members, don't post an activity item either
    	// Removed, I want updated posted if it sends and email or not.
    	/*if ( empty( $notify_members ) ) {
    		return;
    	}*/
    
    	$group = groups_get_group( array(
    		'group_id' => $group_id,
    	) );
    
    	/*
    	 * Store the changed data, which will be used to generate the activity
    	 * action. Since we haven't yet created the activity item, we store the
    	 * old group data in groupmeta, keyed by the timestamp that we'll put
    	 * on the activity item.
    	 */
    	
    	if ( $group->name !== $old_group->name || $group->description !== $old_group->description )
    		$changed = 'changed';
    
    	// If there are no changes, don't post an activity item.
    	if ( empty( $changed ) )
    		return;
    
    	$time = bp_core_current_time();
    	// Don't want a long description of what has been changed inside the details. Also reduces information posted in groupmeta table.
    	//groups_update_groupmeta( $group_id, 'updated_details_' . $time, $changed );
    	
    	// And finally, update groups last activity.. Currently doesn't in standard.
    	groups_update_groupmeta( $group_id, 'last_activity', $time );
    	
    	// Since we have removed the information from meta, we will record it directly into action on activity..
    	// You do not need the same information recorded twice in the database. This needs optimizing. Hence removing update groupmeta..
    	/*
    	$user_link = bp_core_get_userlink( bp_loggedin_user_id() );
    	$group_link = '<a href="' . esc_url( bp_get_group_permalink( $group ) ) . '">' . esc_html( $group->name ) . '</a>';
    	$action = sprintf( __( '%1$s changed the description of the group %2$s from "%3$s" to "%4$s"', 'buddypress' ), $user_link, $group_link, esc_html( $changed['description']['old'] ), esc_html( $changed['description']['new'] ) );
    	*/
    	// Record in activity streams.
    	return groups_record_activity( array(
    		'type'          => 'group_details_updated',
    		'item_id'       => $group_id,
    		'user_id'       => bp_loggedin_user_id(),
    		'recorded_time' => $time,
    	) );
    }

    If there is bugs in any code, I will find them and fix them.. That’s one of the downsides to being a perfectionist..

    I have not fixed the

    A few bugs I have found.

    From the first post yet, but will be doing after I have had my dinner 🙂
    My idea is to have a notification saying that the user has left the group when they leave/kicked/banned/ obviously if its after the 5 minutes mark lol.


    aljo1985
    Participant

    @aljo1985

    Have you tried the WP members only plugin?
    https://wordpress.org/plugins/buddypress-members-only/

    This will restrict your whole website also to members only.
    If you want to just restrict one part of the website, I can help you build a simple function to do this.

    What does the link look like
    http://www.example.com/groups/blah blah blah ??
    Is that what you are trying to block non mebers access to?


    aljo1985
    Participant

    @aljo1985

    Thanks for the info, I am actually new to WordPress and have not looked through all the functions. I have only built custom queries on custom tables on my own website that I am currently developing.
    I have tried wordpress in the past but then switched to other platforms as they was more adequate for my goals.

    But right now I am sticking with wordpress and building a new website :),
    I’m more use to sources and templates, scripting from scratch.

    Out of curiosity, which one is better on performance? A straight up query OR the function above.
    If there is security concerns with using a query, apart from sanitisation which I know and use on every custom table, then that info would be good to know also.

    Thanks.

    Edit, I would like to report a bug in your software, even though you posted this reply I got a notification for a reply in the first topic I made. I had no idea you replied to this other than looking through the latest list of topics.

    Here is a screen shot
    target=”_blank”>https://i.imgur.com/wxSgfsG.png

    Here is the topic in question that I got the notification for which only has 1 reply, but was from other topics.
    https://buddypress.org/support/topic/how-do-i-remove-textarea-resize-without-editing-the-js-script/?action=bbp_mark_read&topic_id=236164&_wpnonce=d849ee20f9#post-236164


    aljo1985
    Participant

    @aljo1985

    Just do a select query to the wordpress database. and echo the results.

    // Query
    global $wpdb;
    $rows = $wpdb->get_results("
    	SELECT id, display_name
    	FROM " . $wpdb->prefix . "users
    	ORDER BY id DESC LIMIT 20"
    );
    // Show 'em...
    foreach($rows as $row):
    	echo $row->display_name;
    endforeach;

    Just change limit, to how many you want to display and DESC to ASC for order.

    Enjoy, my last post!


    aljo1985
    Participant

    @aljo1985

    I think your tone of reading is a bit … maybe you should read in a happy tone! Or maybe you just don’t like to be corrected when you make a mistake..

    Also no the code you posted doesn’t work. It did not remove the feeds nor remove the information from the header.. So it did neither and I am not the only person saying this. I put this script right at the bottom of my themes functions.php file, so its loaded right at the very end and nothing happened. The link you posted is in relation to post titles. The problem the person was having was, it was always putting “activate” in his titles. My problem is I am missing the domain name from the title. Its a totally different issue. When you reply with a copy and pasted answer from something you searched that isn’t even correct, then you might get a bad reply!

    As a moderator you should know how to treat people and you obviously replied to a subject that you didn’t read properly.

    I have not installed SEO yet, so there is no conflict with any other plugins. I will be installing Yoast SEO though.

    EDIT – (The code you posted, I already tried before you posted it)
    If you wanna talk about rude, its rude you accuse me of not searching in the first place when I did.
    I thought it might be quicker to ask if anyone else has the answer already, rather than sift though the massive amounts of scripts this plugin uses (That’s what I meant by messy) EDIT

    EDIT


    aljo1985
    Participant

    @aljo1985

    Okay tell me where the function is that throws these rss tag elements into the header, I can’t find the function that inserts them, too many files.

    I will fix it myself from there once I can locate where it s inserting them in the first place. I imagine its probably scattered all over the place and one file inserts one while another file inserts another.. The code is messy.


    aljo1985
    Participant

    @aljo1985

    The RSS functions you gave me do not work.. Every other person who asked the same question has said the exact same thing. It does not work.. I can disable access to the feeds easily… Using substr – 6 for /feed/ That’s simple! I just want the feeds removing from the header.. They are not used, so I don’t need them in the header.

    remove_action( 'bp_head', 'bp_activity_sitewide_feed');

    This code above, removed the sites activity feed, your code does nothing…

    The 2nd link you gave me, doesn’t solve my problem.. Domain name is missing from the page titles.
    I would like to fix this without creating child themes and without editing any of the source files..

    Basically in a function that can be placed in functions.php as I do all my edits there.

    I’m clean precise and a perfectionist 😛

    This is my themes header that displays the title.
    <title><?php wp_title( '-', true, 'right' ); ?></title>

Viewing 7 replies - 1 through 7 (of 7 total)
Skip to toolbar