Skip to:
Content
Pages
Categories
Search
Top
Bottom

@all / Mention everyone at once.


  • ElbowRobo
    Participant

    @elbowrobo

    I have had a crack at this, and it worked a little but:
    1) it’s too hacky (editing core files)
    2) it broke activity replies (no text in a reply)

    So what do you guys think about this:

    /wp-content/plugins/buddypress/bp-activitybp-activity-filters.php
    `/**
    * Finds and links @-mentioned users in the contents of activity items
    *
    * @since 1.2.0
    *
    * @param string $content The activity content
    * @param int $activity_id The activity id
    *
    * @uses bp_activity_find_mentions()
    * @uses bp_is_username_compatibility_mode()
    * @uses bp_core_get_userid_from_nicename()
    * @uses bp_activity_at_message_notification()
    * @uses bp_core_get_user_domain()
    * @uses bp_activity_adjust_mention_count()
    *
    * @return string $content Content filtered for mentions
    */
    function bp_activity_at_name_filter( $content, $activity_id = 0 ) {
    global $wpdb;

    $usernames = bp_activity_find_mentions( $content );

    if(is_site_admin() && in_array(“all”, $usernames)){
    $all_users = $wpdb->get_col( $wpdb->prepare(“SELECT $wpdb->users.user_login FROM $wpdb->users”));
    foreach($all_users as $i_users){
    array_push($usernames, $i_users);
    }
    }

    if ( !$usernames = array_unique( $usernames ) )
    return false;

    foreach( (array)$usernames as $username ) {
    if ( bp_is_username_compatibility_mode() )
    $user_id = username_exists( $username );
    else
    $user_id = bp_core_get_userid_from_nicename( $username );

    if ( empty( $user_id ) )
    continue;

    // If an activity_id is provided, we can send email and BP notifications
    if ( $activity_id ) {
    bp_activity_at_message_notification( $activity_id, $user_id );
    }

    $content = preg_replace( ‘/(@’ . $username . ‘b)/’, “@$username“, $content );
    }

    // Adjust the activity count for this item
    if ( $activity_id )
    bp_activity_adjust_mention_count( $activity_id, ‘add’ );

    return $content;
    }`

    (The site admin check is to stop spamming :))
    And also, how would I go about using this as part of a plugin (I think i’d have to use add and remove filter or something).
    If anyone can take a look at this and point me in the right direction to get all this working i’d be grateful!

    – Eliott

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

  • ElbowRobo
    Participant

    @elbowrobo

    Hmmm… I thought more people might want to utilise this sort of feature!


    modemlooper
    Moderator

    @modemlooper

    You could create a function that if user is admin a check near update box all users get a notification. Funny you bring this up because I am working on an Extended Notification plugin and this is one of the features.

    I wouldn’t go hacking the @mentions code.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘@all / Mention everyone at once.’ is closed to new replies.
Skip to toolbar