Skip to:
Content
Pages
Categories
Search
Top
Bottom

inbox to new user automatic from admin


  • jennifersanchez
    Participant

    @jennifersanchez

    Hi!
    I found this code to send a welcome message to the inbox of the user by role, but it doesnt works, any suggestion?
    Thanks very much!!

    function send_message_to_new_member( $user_id, $key, $user ) {
    
        if ( ! bp_is_active( 'messages' ) )
            return;
    
        $args = array(
            'sender_id' => 1,
            'thread_id' => false,
            'recipients' => $user_id,
             'role' => 'author',
            'subject' => 'Hello new user',
            'content' => 'Welcome to the site',
            'date_sent' => bp_core_current_time()
        );
    
        $result = messages_new_message( $args );
    }
    add_action( 'bp_core_activated_user', 'send_message_to_new_member', 3 );
Viewing 3 replies - 1 through 3 (of 3 total)

  • shanebp
    Moderator

    @shanebp

    There is no role argument. And recipients takes an array.

    messages_new_message

    Try:

        $recipients = array( $user_id );
    
        $args = array(
            'sender_id' => 1,
            'thread_id' => false,
            'recipients' => $recipients,
            'subject' => 'Hello new user',
            'content' => 'Welcome to the site',
            'date_sent' => bp_core_current_time()
        );

    jennifersanchez
    Participant

    @jennifersanchez

    Hi! i tried but it isnt work.. i mean one message inside buddypress inbox like a user write to another.. is it?

    function send_message_to_new_member( $user_id, $key, $user ) {
    
        if ( ! bp_is_active( 'messages' ) )
            return;
    $recipients = array( $user_id );
    
        $args = array(
            'sender_id' => 1,
            'thread_id' => false,
            'recipients' => $recipients,
            'subject' => 'Hello new user',
            'content' => 'Welcome to the site',
            'date_sent' => bp_core_current_time()
        );
    
        $result = messages_new_message( $args );
    }
    add_action( 'bp_core_activated_user', 'send_message_to_new_member', 3 );

    jennifersanchez
    Participant

    @jennifersanchez

    Warning: Cannot modify header information – headers already sent by (output started at public_html/home/wp-content/mu-plugins/message.php:1) in /public_html/home/wp-content/themes/eonet/inc/hooks.php on line 347

    Warning: Cannot modify header information – headers already sent by (output started at public_html/home/wp-content/mu-plugins/message.php:1) in public_html/home/wp-admin/includes/misc.php on line 1198

Viewing 3 replies - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.
Skip to toolbar