BuddyDev

Search

Mail notifications on BuddyPress Group Activities Notifier

  • Participant
    Level: Initiated
    Posts: 7
    arisanz on #36447

    Hello there!

    I’d like to notificate everything’s happening in my groups and I found there was a code to notify by email with BuddyPress Group Activities Notifier, but isn’t working for me…

    I’ve tried BuddyPress BuddyPress Group Email Subscription but it don’t fix in my idea of the webpage.

    Can you help me with notificating the activity of the group algo by email?

    Thanks!

  • Keymaster
    (BuddyDev Team)
    Posts: 21806
    Brajesh Singh on #36459

    Hi,
    Welcome to BuddyDev forums.

    Please install a mail logging plugin such as mail catcher
    https://wordpress.org/plugins/wp-mail-catcher/

    Please let me know if it show the mails or not?

    Regards
    Brajesh

  • Participant
    Level: Initiated
    Posts: 7
    arisanz on #36503

    Not working,

    I need to notificate by mail of all the activity in the groups. No only by internal notifications the most impotant is to send an email to every member of the group.

  • Participant
    Level: Initiated
    Posts: 7
    arisanz on #36504

    I saw there is a code to send emails to everyone about the group activity but isn’t working in mi web.

    The text was:

    “Notify by email:-
    This plugin does not support notification by email out of the box. The email notifications are resource intensive and based on the number of members of group, may cause timeouts. If you still believe that you want the email notification, you can put the following code in your bp-custom.php

    PHP
    function buddydev_mail_on_new_group_activity( $user_ids, $args ) {

    if ( empty($user_ids ) ) {
    return ;
    }
    //do a bulk query
    $users = get_users( array( ‘include’ => $user_ids ) );

    $group = new BP_Groups_Group( $args[‘group_id’] );
    $loggedin_user_display_name = bp_get_loggedin_user_fullname();

    $activity = new BP_Activity_Activity( $args[‘activity_id’] );

    $activity_content = $activity->content;
    $activity_permalink = bp_activity_get_permalink( $activity->id, $activity );

    $subject = sprintf( ‘%1$s posted to %2$s’, $loggedin_user_display_name, $group->name );
    $message = <<<‘MAINCONTENT’
    Hi %1$s,
    %2$s posted…

    %3$s

    Link: %4$s
    MAINCONTENT;

    foreach ( $users as $user ) {
    $message = sprintf( $message, $user->displayname, $loggedin_user_display_name, $activity_content, $activity_permalink );
    wp_mail( $user->user_email, $subject, $message );
    }
    }
    add_action( ‘bp_group_activities_notify_members’, ‘buddydev_mail_on_new_group_activity’, 10, );
    function buddydev_mail_on_new_group_activity( $user_ids, $args ) {

    if ( empty($user_ids ) ) {
    return ;
    }
    //do a bulk query
    $users = get_users( array( ‘include’ => $user_ids ) );

    $group = new BP_Groups_Group( $args[‘group_id’] );
    $loggedin_user_display_name = bp_get_loggedin_user_fullname();

    $activity = new BP_Activity_Activity( $args[‘activity_id’] );

    $activity_content = $activity->content;
    $activity_permalink = bp_activity_get_permalink( $activity->id, $activity );

    $subject = sprintf( ‘%1$s posted to %2$s’, $loggedin_user_display_name, $group->name );
    $message = <<<‘MAINCONTENT’
    Hi %1$s,
    %2$s posted…

    %3$s

    Link: %4$s
    MAINCONTENT;

    foreach ( $users as $user ) {
    $message = sprintf( $message, $user->displayname, $loggedin_user_display_name, $activity_content, $activity_permalink );
    wp_mail( $user->user_email, $subject, $message );
    }
    }
    add_action( ‘bp_group_activities_notify_members’, ‘buddydev_mail_on_new_group_activity’, 10, 2 );

  • Participant
    Level: Initiated
    Posts: 7
    arisanz on #36505

    Thanks for helping!

  • Keymaster
    (BuddyDev Team)
    Posts: 21806
    Brajesh Singh on #36527

    Hi,
    Thank you for the reply.

    Where have you put the code(which file).

    Please share the complete code from the file on pastebin.com and link me.

    Thank you
    Brajesh

  • Participant
    Level: Initiated
    Posts: 7
    arisanz on #36539

    Hello Brajesh,

    This is the code I’m trying to use. I’ve created a bp-custom folder and inside I’ve created a file named bp-custom.

    I don’t know if I’m doing well, please tell me.

    https://pastebin.com/ggTzpYdb

    So thankfull!

  • Keymaster
    Level: Yogi
    (BuddyDev Team)
    Posts: 2459
    Ravi on #36544

    Hello Arisanz,

    Please take the following resource to get complete knowledge for bp-custom.php file.

    https://buddydev.com/docs/buddypress-guides/what-is-bp-custom-php/

    Give it a shot and let me know if it works or not.

    Regards
    Ravi

    • This reply was modified 1 year, 7 months ago by Ravi.
  • Keymaster
    (BuddyDev Team)
    Posts: 21806
    Brajesh Singh on #36559

    Hi,
    Please create a file as suggested by Ravi above.
    Your current location for bp-custom is incorrect. The file bp-custom.php should go into the wp-content/plugins directory.

    Regards
    Brajesh

  • Participant
    Level: Initiated
    Posts: 7
    arisanz on #36585

    Hi guys thank you!

    Something wrong it’s happening when I create the file bp-custom.php

    The content of the code is appearing before the header of my page. Please, I need to know if the text I’m writing in this file is correct maybe I’m not writing the correct code.

    Thanks for your help!!

You must be logged in to reply to this topic.

This topic is: not resolved