BuddyDev

Search

Can somebody help me with this snippet code?

  • Participant
    BuddyDevFan on #43040

    Hi, somebody posted this snippet back in 2016 where it sends a automaticly message to new users.

    In the ‘date_sent’ it sends the message instant on registration – How can i edit this code so the messages gets sendt 5 minutes after registration?

    //Welcome PM //

    function send_message_to_new_member( $user_id) {

    if ( ! bp_is_active( ‘messages’ ) )
    return;

    $args = array(
    ‘sender_id’ => 9,
    ‘thread_id’ => false,
    ‘recipients’ => $user_id,
    ‘subject’ => ‘Hei! :)’,
    ‘content’ => ‘Hei, hvor holder du til?’,
    ‘date_sent’ => bp_core_current_time()
    );

    $result = messages_new_message( $args );
    }
    add_action( ‘bp_core_activated_user’, ‘send_message_to_new_member’, 1 );
    //End Welcome PM//

  • Keymaster
    (BuddyDev Team)
    Posts: 24211
    Brajesh Singh on #43091

    Hi,
    Welcome to BuddyDev.

    Thank you for the question. It’s an interesting question.

    In order to achieve the delayed message, we need to maintain a queue of message and replay it after 5 mins of registration.

    WordPress does not offer native queue ability, so we will need to manage a custom queue and use the cron functionality of WordPress to achieve it.

    To be honest, It changes from couple of lines to a bit more.

    I am asking one my colleagues to put the code as a simple one page plugin for you. we will link you to the plugin in next couple of days.

    PS:- I and my team sincerely appreciate your feeling. Thank you for joining BuddyDev. We will appreciate if you change the display name as it may confuse people.

    Thank you
    Brajesh

You must be logged in to reply to this topic.

This topic is: not resolved