Skip to:
Content
Pages
Categories
Search
Top
Bottom

Search Results for '@mention on profile'

Viewing 25 results - 1 through 25 (of 129 total)
  • Author
    Search Results
  • #331880
    teeboy4real
    Participant

    I had the option Allow activity stream commenting on posts and comments disabled I also have some code in custom.php file. I am not sure if it could have any effect

    /* Disable comment for all activity but still enable @mention autosuggestion. */
    function disable_activity_comments($can_comment, $activity) {
        // Disable comments
        $can_comment = false;
        return $can_comment;
    }
    add_filter('bp_activity_can_comment', 'disable_activity_comments', 10, 2);
    
    /* Hide comment from activity page */ 
    add_action( 'bp_after_has_activities_parse_args', function ( $r ) {
        if ( bp_is_activity_directory() || bp_is_single_activity() ) {
            $r['display_comments'] = false;
        }
        return $r;
    } );
    
    // Exclude activity updates from subscribers who are not logged in on the activity directory page.
    function hide_new_member_activities_from_unlogged_users( $args ) {
        if ( ! is_user_logged_in() ) {
            $args['action'] = array(
                'activity_comment',
                'activity_update',
                'last_activity',
                'new_avatar',
                'new_blog_comment',
                'new_blog_post',
    			'new_classified',
                'updated_profile'
            );
        }
        return $args;
    }
    add_filter( 'bp_after_has_activities_parse_args', 'hide_new_member_activities_from_unlogged_users' );
    
    #320356
    Mad-As-A-Writer
    Participant

    Just wanted to say a HUGE thank you to @tatiana_k, using your tutorial I was able to find the bp_nouveau_member_hook( 'before', 'header_meta' ); hook in the Buddyboss member-header.php and in that I added an action to insert a profile field “tagline” below a user’s name on their profile. So before, a profile showed the avatar and Name, then on the next line the @mentionname but now it shows Avatar, Name, TAGLINE FROM PROFILE FIELD, @mentionname etc.

    My code:

    /*Add profile field 'tagline' to member profile, below member name*/
    add_action( 'bp_before_member_header_meta' , 'insert_tagline_in_profile' );
    function insert_tagline_in_profile(){
        $webdata = bp_get_member_profile_data( 'field=Tagline' );
    	if( $webdata != false )
    	echo '<div class="member-tagline">' . $webdata . '</div>';
        }

    Note, if you are using a profile field like Favourite Quote, you would replace Tagline in the field above with your field, ie ‘field=Favourite Quote’.

    Thanks to Tatiana I was able to realise I needed bp_before_member_header_meta as the hook, by adding bp / before (from the bp_nouveaux function) / member (because it’s inside the member section) / header_meta (from the bp_nouveaux function).

    If you want another example, I was able to use it to display the same field in the Activity Feed, but in this case I ended up adding the code directly to a template file copied into my child functions.php instead of using the hook, because I wanted the data nested in with the name etc instead of on the line below, but in case it helps anyone, the code to add a profile field below the user info in the activity feed is:

    /*add Tagline to activity feed user info using nouveau loop - no good for me as it
    inserts after the user header instead of inside it*/
    add_action( 'bp_before_activity_activity_content' , 'insert_tagline_in_feed' );
    function insert_tagline_in_feed(){
        $profile_id = bp_get_activity_user_id();
          $tagline_data = xprofile_get_field_data( 'Tagline', $profile_id);
          if( $tagline_data != false ){
              echo '<div class="activity-tagline">' . $tagline_data . '</div>';
          }
        }

    Once again my heartfelt thanks!

    #312025
    shonty
    Participant

    Hi guys,

    I’d like to use Activity Streams but not with @mentions. My users find it confusing having a display name and then their login name shows under their profile pic for @mention purposes. Trying to explain it to them is annoying. It also looks confusing.

    I see that when I use the @mention I can find them by their display name anyway and their login name (@mention name) is beside it. If there are duplicate display names I just scroll down the list until I find the right one. So, it doesnt really need to show their login name as the @mention does it?

    Anyway. I cannot find a way to remove @mentions unless I turn off Activity Streams.

    If I turn off Activity Streams I also lose the ability to comment on a photo with a photo, with RT Media. Because they require Activity Streams to be activated for that to work. Again, very annoying.

    Buddypress Groups is also useless without Activity Streams.

    So is Friends.

    At the moment it is easier to have Activity Streams turned off, than deal with the confusion but what a shame I cant use Activity Streams without it. Then I could use friends and groups and NOT confuse my users with @mentions.

    Any help would be awesome. I did find a plugin called “No @mention” and it crashed my site.

    Thank you all

    woofy123
    Participant

    @prashantvatsh

    Hi Prashant Sir,

    I didn’t know how to reach to you and so I had to reply to this thread.

    I am having a problem and I think you might be able to help me.

    I have this plugin called wise chat pro and it says they integrate buddypress and what I want to do is the following—

    1. When new messages arrive in the wise chat channel they appear in the users bp-profile under the bp-notifications
    2. whenever a user is mentioned in a chat—that also appears in the users bp-profile under the mentions column.

    So in short, how can I connect both plugins so that the new messages and the @mentions appear in the users bp profile under the notification nd mentions section.

    I’ve seen a lot of replies by you and one reply helped me show user profile on a blank page so I thought you could help me with this too..

    Thank you very much

    #310179
    fantasticant
    Participant

    Hi,

    I am using Thrivecart and Wishlist member to create members for my buddypress membership site.

    I can’t seem to stop this from making the users email address immediately public, it shows as the name in profile menu – and also @mentions, and is in their profile url.

    While I have workarounds – and can hide this information using CSS, I would prefer for the system to pick firstname or fullname as the profile name.

    How do I achieve this? .. as users will be concerned at keeping email address private.

    Your help is much appreciated.

    Ant

    #308395
    tom durocher
    Participant

    Hi @dcavins. Just @mentioning you in case you’re not subscribed. I think you code can work for me if we can just get the Forum name back to being savable.

    After looking at the original function in the link you posted, I’m guessing that updating the nickname with $fullname is not wrong, but it doesn’t seem to be working. I notice that this function in the original code is attached to two actions that are different than the one you had me attach to. Could this be the problem? Remember, I have removed the original xprofile_sync function.

    add_action( 'bp_core_signup_user',      'xprofile_sync_wp_profile' );
    add_action( 'bp_core_activated_user',   'xprofile_sync_wp_profile' );
    

    Thanks,
    Tom

    naeemdh
    Participant

    @mention does not show notification under profile mention page if posted in forums post but it does work if somebody mention a user on activity page is there any solution

    coolhunt
    Participant

    hey guys..

    my standard (most recent updated WP/BP install) doesnt have a link to the @username when @mention on the profile field of a user.

    you guys have any ideas how to enable @mention inside buddypress profile fields

    ghosted
    Participant

    I’m trying to get notifications for @mentions to work on a custom loaded discussion area. I was hoping just calling the form would work, the @ links come up but no notifications end up in the targets profile and i’m not sure why. Code i have is:

    `if ( (comments_open() || ‘0’ != get_comments_number()) ) :
    comments_template();

    endif;

    Anyone know how i would get the notifications to work or what i would have to add to this?

    ghosted
    Participant

    Hi all,
    I have a page where people can leave comments but for some reason notifications from that page don’t populate back to the targeted users profile notifications. the system is working across the usual parts of the site (post comments, etc). Does anyone know what code i would need to insert in the backend to have mentions return from this page back to the targeted members notifications tab.

    thanks for any help

    Venutius
    Moderator

    Yep @mentions is a part of the Activity Streams component so turning this off will also remove the @username since this can no longer be used.

    You could always overload the members profile header page you are using and add the username back in, however what good would that do since that username is only used in activity feed `@mentions’ it’s the wp username, not the BP displayname. So I guess it really depends on what you are aiming for.

    Anonymous User 13302461
    Inactive

    As an admin and people @mention me a lot on bbpress, I’m getting a ton of emails when people keep quoting a post that I was mentioned in.

    Please can we disable mentions when they are inside a quote? THe person has already been notified when the OP did the mention. Please remove this bombardment of emails when users keep quoting the OP.

    Thank you. Also I have no option in my profile settings (on my website) about mentions, so I cannot even disable email notifications. Maybe as I have activity stream disabled?

    #268313
    Humiges
    Participant

    Dear Buddypress,

    I hope you can help me with this…
    I have just transferred 1000s of comments to articles – of my buddypress wordpress site.

    Those comments, have @mentions in them and users, didn’t receive the notifications about @mentions – which is great! It would be too much (some of them are old ect).

    However, is there any way we can populate those mentions, without any notifications, so they show in their profiles – under mentions? So, they can look back when someone mentioned them?

    Thank you very much 🙂

    #266476
    coolhunt
    Participant

    Hey Guys,

    is there a way to insert the mentions tab in to the profile tab so that when the profile is displayed in automatically includes that users @mentions?
    Using twenty seventeen theme

    #261682
    sweeneytodd94
    Participant

    (Latest version of WP/BP; non-bundled custom theme, using child theme.)

    When adding a custom index & members-loop to /members/ in my child-theme, to make some adjustments to the members directory layout, individual profile pages break completely, I think defaulting to the pages.php but loaded without any content.

    childtheme/members/members-loop.php

    <?php 
    //global $members_template;
    //$reset_members_template = $members_template;
    
    do_action( 'bp_before_members_loop' ); ?>
    
    <?php if ( bp_has_members( bp_ajax_querystring( 'members' ) . '&per_page=21&type=alphabetical' ) ) : ?>
    
    	<div id="pag-top" class="pagination">
    		<div class="pag-count" id="member-dir-count-top"><?php bp_members_pagination_count(); ?></div>
    		<div class="pagination-links" id="member-dir-pag-top"><?php bp_members_pagination_links(); ?></div>
    	</div>
    
    	<?php do_action( 'bp_before_directory_members_list' ); ?>
    
    	<ul id="members-list" class="item-list" role="main">
    
    	<?php while ( bp_members() ) : bp_the_member(); ?>
    
    		<li>
    			<div class="item-avatar">
    				<a href="<?php bp_member_permalink(); ?>"><?php bp_member_avatar('type=full&width=80&height=80'); ?></a>
    			</div>
    			<div class="item">
    				<div class="item-title"><a href="<?php bp_member_permalink(); ?>"><?php bp_member_name(); ?></a></div>
    				<div class="item-meta"><span class="activity"><?php bp_member_last_active(); ?></span></div>
    				<?php do_action( 'bp_directory_members_item' ); ?>
    			</div>
    			<div class="action">
    				<?php do_action( 'bp_directory_members_actions' ); ?>
    			</div>
    			<div class="clear"></div>
    		</li>
    
    	<?php endwhile; ?>
    
    	</ul>
    
    	<?php do_action( 'bp_after_directory_members_list' ); ?>
    
    	<?php bp_member_hidden_fields(); ?>
    
    	<div id="pag-bottom" class="pagination">
    		<div class="pag-count" id="member-dir-count-bottom"><?php bp_members_pagination_count(); ?></div>
    		<div class="pagination-links" id="member-dir-pag-bottom"><?php bp_members_pagination_links(); ?></div>
    	</div>
    
    <?php else: ?>
    	<div id="message" class="info"><p><?php _e( "Sorry, no members were found.", 'buddypress' ); ?></p></div>
    <?php endif; 
    
    //$members_template = $reset_members_template;
    ?>
    
    <?php do_action( 'bp_after_members_loop' ); ?>

    childtheme/members/index.php

    <?php
    
    /**
     * BuddyPress - Members Directory
     *
     * @package BuddyPress
     * @subpackage bp-default - SSSMG
     */
    
    get_header( 'buddypress' ); ?>
    
    	<?php do_action( 'bp_before_directory_members_page' ); ?>
    
    <div class="container">
    <div class="row">
    <div id="primary" class="col-md-10">
    
    	<div id="content" role="main" class="<?php do_action( 'content_class' ); ?>">
    		<div class="padder">
    		<div class="buddypress">
    
    		<?php do_action( 'bp_before_directory_members' ); ?>
    		
    	<form action="" method="post" id="members-directory-form" class="dir-form">
    	
    	<?php do_action( 'bp_before_directory_members_content' ); ?>
    
    	<div id="members-dir-search" class="dir-search" role="search">
    		<?php bp_directory_members_search_form(); ?>
    	</div><!-- #members-dir-search -->
    
    	<?php do_action( 'bp_before_directory_members_tabs' ); ?>
    
    		<div class="item-list-tabs" role="navigation">
    			<ul>
    				<li class="selected" id="members-all"><a href="<?php bp_members_directory_permalink(); ?>"><?php printf( __( 'All Members %s', 'buddypress' ), '<span>' . bp_core_get_total_member_count() . '</span>' ); ?></a></li>
    
    				<?php if ( is_user_logged_in() && bp_is_active( 'friends' ) && bp_get_total_friend_count( bp_loggedin_user_id() ) ) : ?>
    					<li id="members-personal"><a href="<?php echo bp_loggedin_user_domain() . bp_get_friends_slug() . '/my-friends/'; ?>"><?php printf( __( 'My Friends %s', 'buddypress' ), '<span>' . bp_get_total_friend_count( bp_loggedin_user_id() ) . '</span>' ); ?></a></li>
    				<?php endif; ?>
    
    				<?php do_action( 'bp_members_directory_member_types' ); ?>
    
    			</ul>
    		</div><!-- .item-list-tabs -->
    
    		<div id="members-dir-list" class="members dir-list">
    			<?php //bp_get_template_part( 'members/members-loop' );
    				locate_template( array( 'members/members-loop.php' ), true );
    			?>
    		</div><!-- #members-dir-list -->
    
    		<?php do_action( 'bp_directory_members_content' ); ?>
    
    		<?php wp_nonce_field( 'directory_members', '_wpnonce-member-filter' ); ?>
    
    		<?php do_action( 'bp_after_directory_members_content' ); ?>
    
    	</form><!-- #members-directory-form -->
    
    	<?php do_action( 'bp_after_directory_members' ); ?>
    
    </div><!-- #buddypress -->
    </div><!-- .padder -->
    	</div><!-- #content -->
    
    </div><!-- primary -->
    <?php get_sidebar( 'buddypress' ); ?>
    </div><!-- row -->
    </div><!-- container -->
    
    	<?php do_action( 'bp_after_directory_members_page' ); ?>
    
    <?php get_footer( 'buddypress' ); ?>

    bp-custom.php

    <?php
    // bp-custom.php - BP hacks and mods will go here
    /**
     * Include bbPress 'topic' custom post type in WordPress' search results */
     
    function ntwb_bbp_topic_cpt_search( $topic_search ) {
    	$topic_search['exclude_from_search'] = false;
    	return $topic_search;
    }
    add_filter( 'bbp_register_topic_post_type', 'ntwb_bbp_topic_cpt_search' );
    
    /**
     * Include bbPress 'forum' custom post type in WordPress' search results */
    
    function ntwb_bbp_forum_cpt_search( $forum_search ) {
    	$forum_search['exclude_from_search'] = false;
    	return $forum_search;
    }
    add_filter( 'bbp_register_forum_post_type', 'ntwb_bbp_forum_cpt_search' );
    
    /**
     * Include bbPress 'reply' custom post type in WordPress' search results  */
    
    function ntwb_bbp_reply_cpt_search( $reply_search ) {
    	$reply_search['exclude_from_search'] = false;
    	return $reply_search;
    }
    add_filter( 'bbp_register_reply_post_type', 'ntwb_bbp_reply_cpt_search' );
    
    /**
     * Ensure that multiselect boxes have trailing brackets in their 'id' and 'name' attributes.
     *
     * These brackets are required for an array of values to be sent in the POST
     * request. Previously, bp_get_the_profile_field_input_name() contained the
     * necessary logic, but since BP 2.0 that logic has been moved into
     * BP_XProfile_Field_Type_Multiselectbox. Since bp-default does not use the
     * BP_XProfile_Field_Type classes to build its markup, it did not inherit
     * the brackets from their new location. Thus this workaround.
     */
    function bp_dtheme_add_brackets_to_multiselectbox_attributes( $name ) {
    	global $field;
    
    	if ( 'multiselectbox' === $field->type ) {
    		$name .= '[]';
    	}
    
    	return $name;
    }
    add_filter( 'bp_get_the_profile_field_input_name', 'bp_dtheme_add_brackets_to_multiselectbox_attributes' );
    
    // add the custom column headers to BP manage signups
    function philopress_modify_user_columns($column_headers) {
            $column_headers['extended'] = 'Extended';
            return $column_headers;
    }
    add_action('manage_users_page_bp-signups_columns','philopress_modify_user_columns');
    
    // dump all the pending user's meta data in the custom column
    function philopress_signup_custom_column( $str, $column_name, $signup_object ) {
    	if ( $column_name == 'extended' ) 
                 return print_r( $signup_object->meta, true );
            return $str;
    }
    add_filter( 'bp_members_signup_custom_column', 'philopress_signup_custom_column', 1, 3 );
    
    //* Redirect WordPress Logout to Home Page
    add_action('wp_logout',create_function('','wp_redirect(home_url());exit();'));
    
    //add @mentions to bbpress forum
    function custom_bbpress_maybe_load_mentions_scripts( $retval = false ) {
    	if ( function_exists( 'bbpress' ) && is_bbpress() ) {
    		$retval = true;
    	}
    	return $retval;
    }
    add_filter( 'bp_activity_maybe_load_mentions_scripts', 'custom_bbpress_maybe_load_mentions_scripts' );
    
    function bphelp_dpioml(){
    	$bphelp_my_profile_field_1='Profession';
    	$bphelp_my_profile_field_2='Primary Institution';
           if( is_user_logged_in() && bp_is_members_component() ) { ?>
            <div class="bph_xprofile_fields">
                              <?php if(bphelp_my_profile_field_1<>"") echo bp_member_profile_data( 'field='.$bphelp_my_profile_field_1 );  ?><br />
    						  <?php if(bphelp_my_profile_field_2<>"") echo bp_member_profile_data( 'field='.$bphelp_my_profile_field_2 );  ?><br />
                    </div><?php
           }
    }
    add_action('bp_directory_members_item', 'bphelp_dpioml');
    
    ?>

    I’ve tried all sorts of different combinations but whatever I do, the only way to get both the profile pages and the members directory to display is to remove the index and members-loop customizations. Then everything works fine, but without the adjustments to the members directory that I want (removing recent updates, for instance). Any pointers would be brilliant!

    #261575
    Steve
    Participant

    I hear ya. I don’t necessarly want them to change their username. But it appears the @mention is connected to it.

    I think it would be better to attach the mention to their profile name (real name), which is changable. And keep the username out of it all together.

    #261260
    cwilliamsusherin
    Participant

    I’m using the directory plugin Geodirectory & am attempting to integrate the @mentions & auto-suggestions from Buddypress into their Add-Listings section. For example: Theatre company posts an event, tag actors (from suggestions) who have a buddypress profile & pull certain data from their profile to display such as; photo, name, bio, etc.

    I’ve been playing with adding the auto-suggestion code to the Geodirectory core files but it isn’t working. Does anyone have any suggestions or can you point me in the right direction?

    ljmac
    Participant

    When using public messaging or third party plug-ins emulating Facebook, it is possible for users to post on other users’ profiles. However, what happens if the person being posted to wants to remove it from their profile?

    For cases like this, please tell me how I could add a delete button to an activity when it is (1) an activity update and (2) the user is @mentioned in the post.

    #254626
    danbp
    Moderator

    Private message

    A user must have friends to send private messages or visit the profile of another user to send him a msg.

    Messages

    To get it to work, you need also to enable following options in BP settings:
    – Friend Connections
    – Private messaging
    Additionnally, if you want to be notified by email
    – Notifications

    Whatever the option you activate, best practice is to control how it works on your config. To do that, use only WP, BP and one of Twenty’s theme before activating a third party theme and any other plugin.
    This will ensure you that BP is fully working on a standart WP config.

    Mention

    @mention use AJAX which can in some case, mostly with sophisticated themes or frameworks, lead to conflict. In that case, the culprit isn’t BP or WP, but the theme or a plugin whose code (generally) use a different standart as WP.

    If you get issues with mention or messaging, activate wp_debug in wp-config and check your browser JS console to track down errors. The one or the other can give you precious debug information. You can also use a debug tool like Firebug.

    #253945
    danbp
    Moderator

    Hi @ariane1001,

    perhaps you need to echo the function ? Anywy, can you test this snippet, to ensure that fullname is fired correctly.

    Add it to bp-custom or to your child theme functions.php.

    
    function bpfr_user_fullname() {
            // uncomment below if you want this only for logged in users.
    	//if ( !is_user_logged_in() )
    		//return false;
    
    	echo bp_displayed_user_fullname();
    	
    }
    add_filter( 'bp_before_member_header_meta', 'bpfr_user_fullname' ); 
    //add_filter( 'bp_get_displayed_user_mentionname', 'bpfr_user_fullname' );

    If you see the fullname in the profile header, you could remove the actual filter and use the other one. Just uncomment the line and you’ll see @mention using the fullname instead of display_name.

    #252314
    Paul Wong-Gibbs
    Keymaster

    Having BP active on all sites in a network just means BP works on all of those sites. By default, the main domain, as you call it, becomes the central hub.

    In practical terms, if you have the Site Tracking component enabled, it’d track blog posts/comments on all sites into the hub’s activity stream. There’s a “Sites” tab in the user profile that will show a list of all the sites that the user has some kind of access to (to the wp-admin).

    There are other things like @mentions that you could get to work (though you’d probably have to write a bit of code to support the non-BuddyPress templates running on the non-hub site(s).

    #251798

    In reply to: New activity tab

    danbp
    Moderator

    Hi,

    first of, read the doc about activities customization.

    If i understand you correctly, you want to allow your users to comment about other users on a extra tab. BP allows activities commenting by default on all activity feeds.

    Also “allow other users to comment on a specific user” can be done by simply using @mention.

    Why and where an extra tab ? On Activity, group or profile activity tab ? How do you imagine such a tab showing up ?

    Please, explain exactly what you want to do. 🙂

    #251464
    danbp
    Moderator

    I’m afraid you can’t built another member’s directory. “Members” is a component and it use a dynamic page to output anything related to members.

    The only thing who change, is eventually the content template part (member directory vs. profile for example: both activity are on the same pseudo “page”.

    The only way i see for your case, is to add a custom filter and to define eventually another default output for member directory, based on the current filter. But it’s the user who has to choose what he want to see there.

    Default filter are recently active, recently subscribed and alphabetical order. To add more option, included “artists”, try to add “member type” or create you r own plugin to filter.

    Here the related codex page for member-type

    And codex page for how to add a filter on members directory.

    For the @ use, the correct way to use it is when you want to mention (@mention) somebody. And so far i can see this here, it doesn’t actually work on bp.org ! 😉

    So just keep in mind that you publish on a public forum. It is not intended to call mods individually. We’re not consultants here (we don’t charge you), but simple volonteers trying to guide and help other users.

    #251189
    btees
    Participant

    Hey Guys,

    I hope this is in the right section.

    I’m using awpcp for wordpress to create a classified ads website (for people to swap stuff they no longer use, not sell it!)

    Awpcp has a comment form plugin but it’s extremely basic, at the moment it’s just adding plain text to the bottom of the page when someone comments.

    I’ve been able to edit it so the username links to the users buddypress profile, but I’d really like @mentions to link to profiles and send notifications to users tagged, appear in activity feeds, etc.

    Right now it just shows up as plain text.

    Can anyone steer me in the right direction as to how I might achieve this?

    Cheers guys 🙂

    #248285
    ibuddybook
    Participant

    Thank you for your reply Mr.Henry Wright…

    How to insert the code????? how to change the Parameters???. i am not understand. please tell me step by step…

    here is my code…
    /buddypress/bp-activity/bp-activity-notifications.php

    <?php
    /**
     * BuddyPress Activity Notifications.
     *
     * @package BuddyPress
     * @subpackage ActivityNotifications
     */
    
    // Exit if accessed directly.
    defined( 'ABSPATH' ) || exit;
    
    /* Emails *********************************************************************/
    
    /**
     * Send email and BP notifications when a user is mentioned in an update.
     *
     * @since 1.2.0
     *
     * @uses bp_notifications_add_notification()
     * @uses bp_get_user_meta()
     * @uses bp_core_get_user_displayname()
     * @uses bp_activity_get_permalink()
     * @uses bp_core_get_user_domain()
     * @uses bp_get_settings_slug()
     * @uses bp_activity_filter_kses()
     * @uses bp_core_get_core_userdata()
     * @uses wp_specialchars_decode()
     * @uses get_blog_option()
     * @uses bp_is_active()
     * @uses bp_is_group()
     * @uses bp_get_current_group_name()
     * @uses apply_filters() To call the 'bp_activity_at_message_notification_to' hook.
     * @uses apply_filters() To call the 'bp_activity_at_message_notification_subject' hook.
     * @uses apply_filters() To call the 'bp_activity_at_message_notification_message' hook.
     * @uses wp_mail()
     * @uses do_action() To call the 'bp_activity_sent_mention_email' hook.
     *
     * @param int $activity_id      The ID of the activity update.
     * @param int $receiver_user_id The ID of the user who is receiving the update.
     */
    
    function bp_activity_at_message_notification( $activity_id, $receiver_user_id ) {
    
    	// Don't leave multiple notifications for the same activity item.
    	$notifications = BP_Core_Notification::get_all_for_user( $receiver_user_id, 'all' );
    
    	foreach( $notifications as $notification ) {
    		if ( $activity_id == $notification->item_id ) {
    			return;
    		}
    	}
    
    	$activity = new BP_Activity_Activity( $activity_id );
    
    	$subject = '';
    	$message = '';
    	$content = '';
    
    	// Now email the user with the contents of the message (if they have enabled email notifications).
    	if ( 'no' != bp_get_user_meta( $receiver_user_id, 'notification_activity_new_mention', true ) ) {
    		$poster_name = bp_core_get_user_displayname( $activity->user_id );
    
    		$message_link  = bp_activity_get_permalink( $activity_id );
    		$settings_slug = function_exists( 'bp_get_settings_slug' ) ? bp_get_settings_slug() : 'settings';
    		$settings_link = bp_core_get_user_domain( $receiver_user_id ) . $settings_slug . '/notifications/';
    
    		$poster_name = stripslashes( $poster_name );
    		$content = bp_activity_filter_kses( strip_tags( stripslashes( $activity->content ) ) );
    
    		// Set up and send the message.
    		$ud       = bp_core_get_core_userdata( $receiver_user_id );
    		$to       = $ud->user_email;
    		$subject  = bp_get_email_subject( array( 'text' => sprintf( __( '%s mentioned you in an update', 'buddypress' ), $poster_name ) ) );
    
    		if ( bp_is_active( 'groups' ) && bp_is_group() ) {
    			$message = sprintf( __(
    '%1$s mentioned you in the group "%2$s":
    
    "%3$s"
    
    To view and respond to the message, log in and visit: %4$s
    
    ---------------------
    ', 'buddypress' ), $poster_name, bp_get_current_group_name(), $content, $message_link );
    		} else {
    			$message = sprintf( __(
    '%1$s mentioned you in an update:
    
    "%2$s"
    
    To view and respond to the message, log in and visit: %3$s
    
    ---------------------
    ', 'buddypress' ), $poster_name, $content, $message_link );
    		}
    
    		// Only show the disable notifications line if the settings component is enabled.
    		if ( bp_is_active( 'settings' ) ) {
    			$message .= sprintf( __( 'To disable these notifications please log in and go to: %s', 'buddypress' ), $settings_link );
    		}
    
    		/**
    		 * Filters the user email that the @mention notification will be sent to.
    		 *
    		 * @since 1.2.0
    		 *
    		 * @param string $to User email the notification is being sent to.
    		 */
    		$to 	 = apply_filters( 'bp_activity_at_message_notification_to', $to );
    
    		/**
    		 * Filters the @mention notification subject that will be sent to user.
    		 *
    		 * @since 1.2.0
    		 *
    		 * @param string $subject     Email notification subject text.
    		 * @param string $poster_name Name of the person who made the @mention.
    		 */
    		$subject = apply_filters( 'bp_activity_at_message_notification_subject', $subject, $poster_name );
    
    		/**
    		 * Filters the @mention notification message that will be sent to user.
    		 *
    		 * @since 1.2.0
    		 *
    		 * @param string $message       Email notification message text.
    		 * @param string $poster_name   Name of the person who made the @mention.
    		 * @param string $content       Content of the @mention.
    		 * @param string $message_link  URL permalink for the activity message.
    		 * @param string $settings_link URL permalink for the user's notification settings area.
    		 */
    		$message = apply_filters( 'bp_activity_at_message_notification_message', $message, $poster_name, $content, $message_link, $settings_link );
    
    		wp_mail( $to, $subject, $message );
    	}
    
    	/**
    	 * Fires after the sending of an @mention email notification.
    	 *
    	 * @since 1.5.0
    	 *
    	 * @param BP_Activity_Activity $activity         Activity Item object.
    	 * @param string               $subject          Email notification subject text.
    	 * @param string               $message          Email notification message text.
    	 * @param string               $content          Content of the @mention.
    	 * @param int                  $receiver_user_id The ID of the user who is receiving the update.
    	 */
    	do_action( 'bp_activity_sent_mention_email', $activity, $subject, $message, $content, $receiver_user_id );
    }
    
    /**
     * Send email and BP notifications when an activity item receives a comment.
     *
     * @since 1.2.0
     *
     * @uses bp_get_user_meta()
     * @uses bp_core_get_user_displayname()
     * @uses bp_activity_get_permalink()
     * @uses bp_core_get_user_domain()
     * @uses bp_get_settings_slug()
     * @uses bp_activity_filter_kses()
     * @uses bp_core_get_core_userdata()
     * @uses wp_specialchars_decode()
     * @uses get_blog_option()
     * @uses bp_get_root_blog_id()
     * @uses apply_filters() To call the 'bp_activity_new_comment_notification_to' hook.
     * @uses apply_filters() To call the 'bp_activity_new_comment_notification_subject' hook.
     * @uses apply_filters() To call the 'bp_activity_new_comment_notification_message' hook.
     * @uses wp_mail()
     * @uses do_action() To call the 'bp_activity_sent_reply_to_update_email' hook.
     * @uses apply_filters() To call the 'bp_activity_new_comment_notification_comment_author_to' hook.
     * @uses apply_filters() To call the 'bp_activity_new_comment_notification_comment_author_subject' hook.
     * @uses apply_filters() To call the 'bp_activity_new_comment_notification_comment_author_message' hook.
     * @uses do_action() To call the 'bp_activity_sent_reply_to_reply_email' hook.
     *
     * @param int   $comment_id   The comment id.
     * @param int   $commenter_id The ID of the user who posted the comment.
     * @param array $params       {@link bp_activity_new_comment()}.
     * @return bool
     */
    function bp_activity_new_comment_notification( $comment_id = 0, $commenter_id = 0, $params = array() ) {
    
    	// Set some default parameters.
    	$activity_id = 0;
    	$parent_id   = 0;
    
    	extract( $params );
    
    	$original_activity = new BP_Activity_Activity( $activity_id );
    
    	if ( $original_activity->user_id != $commenter_id && 'no' != bp_get_user_meta( $original_activity->user_id, 'notification_activity_new_reply', true ) ) {
    		$poster_name   = bp_core_get_user_displayname( $commenter_id );
    		$thread_link   = bp_activity_get_permalink( $activity_id );
    		$settings_slug = function_exists( 'bp_get_settings_slug' ) ? bp_get_settings_slug() : 'settings';
    		$settings_link = bp_core_get_user_domain( $original_activity->user_id ) . $settings_slug . '/notifications/';
    
    		$poster_name = stripslashes( $poster_name );
    		$content = bp_activity_filter_kses( stripslashes($content) );
    
    		// Set up and send the message.
    		$ud      = bp_core_get_core_userdata( $original_activity->user_id );
    		$to      = $ud->user_email;
    		$subject = bp_get_email_subject( array( 'text' => sprintf( __( '%s replied to one of your updates', 'buddypress' ), $poster_name ) ) );
    		$message = sprintf( __(
    '%1$s replied to one of your updates:
    
    "%2$s"
    
    To view your original update and all comments, log in and visit: %3$s
    
    ---------------------
    ', 'buddypress' ), $poster_name, $content, $thread_link );
    
    		// Only show the disable notifications line if the settings component is enabled.
    		if ( bp_is_active( 'settings' ) ) {
    			$message .= sprintf( __( 'To disable these notifications please log in and go to: %s', 'buddypress' ), $settings_link );
    		}
    
    		/**
    		 * Filters the user email that the new comment notification will be sent to.
    		 *
    		 * @since 1.2.0
    		 *
    		 * @param string $to User email the notification is being sent to.
    		 */
    		$to = apply_filters( 'bp_activity_new_comment_notification_to', $to );
    
    		/**
    		 * Filters the new comment notification subject that will be sent to user.
    		 *
    		 * @since 1.2.0
    		 *
    		 * @param string $subject     Email notification subject text.
    		 * @param string $poster_name Name of the person who made the comment.
    		 */
    		$subject = apply_filters( 'bp_activity_new_comment_notification_subject', $subject, $poster_name );
    
    		/**
    		 * Filters the new comment notification message that will be sent to user.
    		 *
    		 * @since 1.2.0
    		 *
    		 * @param string $message       Email notification message text.
    		 * @param string $poster_name   Name of the person who made the comment.
    		 * @param string $content       Content of the comment.
    		 * @param string $thread_link   URL permalink for the activity thread.
    		 * @param string $settings_link URL permalink for the user's notification settings area.
    		 */
    		$message = apply_filters( 'bp_activity_new_comment_notification_message', $message, $poster_name, $content, $thread_link, $settings_link );
    
    		wp_mail( $to, $subject, $message );
    
    		/**
    		 * Fires after the sending of a reply to an update email notification.
    		 *
    		 * @since 1.5.0
    		 *
    		 * @param int    $user_id      ID of the original activity item author.
    		 * @param string $subject      Email notification subject text.
    		 * @param string $message      Email notification message text.
    		 * @param int    $comment_id   ID for the newly received comment.
    		 * @param int    $commenter_id ID of the user who made the comment.
    		 * @param array  $params       Arguments used with the original activity comment.
    		 */
    		do_action( 'bp_activity_sent_reply_to_update_email', $original_activity->user_id, $subject, $message, $comment_id, $commenter_id, $params );
    	}
    
    	/*
    	 * If this is a reply to another comment, send an email notification to the
    	 * author of the immediate parent comment.
    	 */
    	if ( empty( $parent_id ) || ( $activity_id == $parent_id ) ) {
    		return false;
    	}
    
    	$parent_comment = new BP_Activity_Activity( $parent_id );
    
    	if ( $parent_comment->user_id != $commenter_id && $original_activity->user_id != $parent_comment->user_id && 'no' != bp_get_user_meta( $parent_comment->user_id, 'notification_activity_new_reply', true ) ) {
    		$poster_name   = bp_core_get_user_displayname( $commenter_id );
    		$thread_link   = bp_activity_get_permalink( $activity_id );
    		$settings_slug = function_exists( 'bp_get_settings_slug' ) ? bp_get_settings_slug() : 'settings';
    		$settings_link = bp_core_get_user_domain( $parent_comment->user_id ) . $settings_slug . '/notifications/';
    
    		// Set up and send the message.
    		$ud       = bp_core_get_core_userdata( $parent_comment->user_id );
    		$to       = $ud->user_email;
    		$subject = bp_get_email_subject( array( 'text' => sprintf( __( '%s replied to one of your comments', 'buddypress' ), $poster_name ) ) );
    
    		$poster_name = stripslashes( $poster_name );
    		$content = bp_activity_filter_kses( stripslashes( $content ) );
    
    $message = sprintf( __(
    '%1$s replied to one of your comments:
    
    "%2$s"
    
    To view the original activity, your comment and all replies, log in and visit: %3$s
    
    ---------------------
    ', 'buddypress' ), $poster_name, $content, $thread_link );
    
    		// Only show the disable notifications line if the settings component is enabled.
    		if ( bp_is_active( 'settings' ) ) {
    			$message .= sprintf( __( 'To disable these notifications please log in and go to: %s', 'buddypress' ), $settings_link );
    		}
    
    		/**
    		 * Filters the user email that the new comment reply notification will be sent to.
    		 *
    		 * @since 1.2.0
    		 *
    		 * @param string $to User email the notification is being sent to.
    		 */
    		$to = apply_filters( 'bp_activity_new_comment_notification_comment_author_to', $to );
    
    		/**
    		 * Filters the new comment reply notification subject that will be sent to user.
    		 *
    		 * @since 1.2.0
    		 *
    		 * @param string $subject     Email notification subject text.
    		 * @param string $poster_name Name of the person who made the comment reply.
    		 */
    		$subject = apply_filters( 'bp_activity_new_comment_notification_comment_author_subject', $subject, $poster_name );
    
    		/**
    		 * Filters the new comment reply notification message that will be sent to user.
    		 *
    		 * @since 1.2.0
    		 *
    		 * @param string $message       Email notification message text.
    		 * @param string $poster_name   Name of the person who made the comment reply.
    		 * @param string $content       Content of the comment reply.
    		 * @param string $settings_link URL permalink for the user's notification settings area.
    		 * @param string $thread_link   URL permalink for the activity thread.
    		 */
    		$message = apply_filters( 'bp_activity_new_comment_notification_comment_author_message', $message, $poster_name, $content, $settings_link, $thread_link );
    
    		wp_mail( $to, $subject, $message );
    
    		/**
    		 * Fires after the sending of a reply to a reply email notification.
    		 *
    		 * @since 1.5.0
    		 *
    		 * @param int    $user_id      ID of the parent activity item author.
    		 * @param string $subject      Email notification subject text.
    		 * @param string $message      Email notification message text.
    		 * @param int    $comment_id   ID for the newly received comment.
    		 * @param int    $commenter_id ID of the user who made the comment.
    		 * @param array  $params       Arguments used with the original activity comment.
    		 */
    		do_action( 'bp_activity_sent_reply_to_reply_email', $parent_comment->user_id, $subject, $message, $comment_id, $commenter_id, $params );
    	}
    }
    
    /**
     * Helper method to map action arguments to function parameters.
     *
     * @since 1.9.0
     *
     * @param int   $comment_id ID of the comment being notified about.
     * @param array $params     Parameters to use with notification.
     */
    function bp_activity_new_comment_notification_helper( $comment_id, $params ) {
    	bp_activity_new_comment_notification( $comment_id, $params['user_id'], $params );
    }
    add_action( 'bp_activity_comment_posted', 'bp_activity_new_comment_notification_helper', 10, 2 );
    
    /** Notifications *************************************************************/
    
    /**
     * Format notifications related to activity.
     *
     * @since 1.5.0
     *
     * @uses bp_loggedin_user_domain()
     * @uses bp_get_activity_slug()
     * @uses bp_core_get_user_displayname()
     * @uses apply_filters() To call the 'bp_activity_multiple_at_mentions_notification' hook.
     * @uses apply_filters() To call the 'bp_activity_single_at_mentions_notification' hook.
     * @uses do_action() To call 'activity_format_notifications' hook.
     *
     * @param string $action            The type of activity item. Just 'new_at_mention' for now.
     * @param int    $item_id           The activity ID.
     * @param int    $secondary_item_id In the case of at-mentions, this is the mentioner's ID.
     * @param int    $total_items       The total number of notifications to format.
     * @param string $format            'string' to get a BuddyBar-compatible notification, 'array' otherwise.
     * @return string $return Formatted @mention notification.
     */
    function bp_activity_format_notifications( $action, $item_id, $secondary_item_id, $total_items, $format = 'string' ) {
    
    	switch ( $action ) {
    		case 'new_at_mention':
    			$activity_id      = $item_id;
    			$poster_user_id   = $secondary_item_id;
    			$at_mention_link  = bp_loggedin_user_domain() . bp_get_activity_slug() . '/mentions/';
    			$at_mention_title = sprintf( __( '@%s Mentions', 'buddypress' ), bp_get_loggedin_user_username() );
    			$amount = 'single';
    
    			if ( (int) $total_items > 1 ) {
    				$text = sprintf( __( 'You have %1$d new mentions', 'buddypress' ), (int) $total_items );
    				$amount = 'multiple';
    			} else {
    				$user_fullname = bp_core_get_user_displayname( $poster_user_id );
    				$text =  sprintf( __( '%1$s mentioned you', 'buddypress' ), $user_fullname );
    			}
    		break;
    	}
    
    	if ( 'string' == $format ) {
    
    		/**
    		 * Filters the @mention notification for the string format.
    		 *
    		 * This is a variable filter that is dependent on how many items
    		 * need notified about. The two possible hooks are bp_activity_single_at_mentions_notification
    		 * or bp_activity_multiple_at_mentions_notification.
    		 *
    		 * @since 1.5.0
    		 *
    		 * @param string $string          HTML anchor tag for the mention.
    		 * @param string $at_mention_link The permalink for the mention.
    		 * @param int    $total_items     How many items being notified about.
    		 * @param int    $activity_id     ID of the activity item being formatted.
    		 * @param int    $poster_user_id  ID of the user posting the mention.
    		 */
    		$return = apply_filters( 'bp_activity_' . $amount . '_at_mentions_notification', '<a href="' . esc_url( $at_mention_link ) . '" title="' . esc_attr( $at_mention_title ) . '">' . esc_html( $text ) . '</a>', $at_mention_link, (int) $total_items, $activity_id, $poster_user_id );
    	} else {
    
    		/**
    		 * Filters the @mention notification for any non-string format.
    		 *
    		 * This is a variable filter that is dependent on how many items need notified about.
    		 * The two possible hooks are bp_activity_single_at_mentions_notification
    		 * or bp_activity_multiple_at_mentions_notification.
    		 *
    		 * @since 1.5.0
    		 *
    		 * @param array  $array           Array holding the content and permalink for the mention notification.
    		 * @param string $at_mention_link The permalink for the mention.
    		 * @param int    $total_items     How many items being notified about.
    		 * @param int    $activity_id     ID of the activity item being formatted.
    		 * @param int    $poster_user_id  ID of the user posting the mention.
    		 */
    		$return = apply_filters( 'bp_activity_' . $amount . '_at_mentions_notification', array(
    			'text' => $text,
    			'link' => $at_mention_link
    		), $at_mention_link, (int) $total_items, $activity_id, $poster_user_id );
    	}
    
    	/**
    	 * Fires right before returning the formatted activity notifications.
    	 *
    	 * @since 1.2.0
    	 *
    	 * @param string $action            The type of activity item.
    	 * @param int    $item_id           The activity ID.
    	 * @param int    $secondary_item_id @mention mentioner ID.
    	 * @param int    $total_items       Total amount of items to format.
    	 */
    	do_action( 'activity_format_notifications', $action, $item_id, $secondary_item_id, $total_items );
    
    	return $return;
    }
    
    /**
     * Notify a member when their nicename is mentioned in an activity stream item.
     *
     * Hooked to the 'bp_activity_sent_mention_email' action, we piggy back off the
     * existing email code for now, since it does the heavy lifting for us. In the
     * future when we separate emails from Notifications, this will need its own
     * 'bp_activity_at_name_send_emails' equivalent helper function.
     *
     * @since 1.9.0
     *
     * @param object $activity           Activity object.
     * @param string $subject (not used) Notification subject.
     * @param string $message (not used) Notification message.
     * @param string $content (not used) Notification content.
     * @param int    $receiver_user_id   ID of user receiving notification.
     */
    function bp_activity_at_mention_add_notification( $activity, $subject, $message, $content, $receiver_user_id ) {
    	if ( bp_is_active( 'notifications' ) ) {
    		bp_notifications_add_notification( array(
    			'user_id'           => $receiver_user_id,
    			'item_id'           => $activity->id,
    			'secondary_item_id' => $activity->user_id,
    			'component_name'    => buddypress()->activity->id,
    			'component_action'  => 'new_at_mention',
    			'date_notified'     => bp_core_current_time(),
    			'is_new'            => 1,
    		) );
    	}
    }
    add_action( 'bp_activity_sent_mention_email', 'bp_activity_at_mention_add_notification', 10, 5 );
    
    /**
     * Mark at-mention notifications as read when users visit their Mentions page.
     *
     * @since 1.5.0
     *
     * @uses bp_notifications_mark_all_notifications_by_type()
     */
    function bp_activity_remove_screen_notifications() {
    	if ( ! bp_is_active( 'notifications' ) ) {
    		return;
    	}
    
    	// Only mark read if you're looking at your own mentions.
    	if ( ! bp_is_my_profile() ) {
    		return;
    	}
    
    	bp_notifications_mark_notifications_by_type( bp_loggedin_user_id(), buddypress()->activity->id, 'new_at_mention' );
    }
    add_action( 'bp_activity_screen_mentions', 'bp_activity_remove_screen_notifications' );
    
    /**
     * Mark at-mention notification as read when user visits the activity with the mention.
     *
     * @since 2.0.0
     *
     * @param BP_Activity_Activity $activity Activity object.
     */
    function bp_activity_remove_screen_notifications_single_activity_permalink( $activity ) {
    	if ( ! bp_is_active( 'notifications' ) ) {
    		return;
    	}
    
    	if ( ! is_user_logged_in() ) {
    		return;
    	}
    
    	// Mark as read any notifications for the current user related to this activity item.
    	bp_notifications_mark_notifications_by_item_id( bp_loggedin_user_id(), $activity->id, buddypress()->activity->id, 'new_at_mention' );
    }
    add_action( 'bp_activity_screen_single_activity_permalink', 'bp_activity_remove_screen_notifications_single_activity_permalink' );
    
    /**
     * Delete at-mention notifications when the corresponding activity item is deleted.
     *
     * @since 2.0.0
     *
     * @param array $activity_ids_deleted IDs of deleted activity items.
     */
    function bp_activity_at_mention_delete_notification( $activity_ids_deleted = array() ) {
    	// Let's delete all without checking if content contains any mentions
    	// to avoid a query to get the activity.
    	if ( bp_is_active( 'notifications' ) && ! empty( $activity_ids_deleted ) ) {
    		foreach ( $activity_ids_deleted as $activity_id ) {
    			bp_notifications_delete_all_notifications_by_type( $activity_id, buddypress()->activity->id );
    		}
    	}
    }
    add_action( 'bp_activity_deleted_activities', 'bp_activity_at_mention_delete_notification', 10 );
Viewing 25 results - 1 through 25 (of 129 total)
Skip to toolbar