Skip to:
Content
Pages
Categories
Search
Top
Bottom

[Resolved] Need a way to import messages without sending them


  • ernstl
    Participant

    @ernstl

    Hi,

    i am converting a hughe forum to a bbpress forum with buddypress installed.
    Our custom importer also imports messages from the old forum software (CBACK a bbpress clone).
    The problem is that imported messages are send through buddypress on import.

    We disabled in PHP.ini

    disable_functions = ‘mail’;
    disable_functions = ‘fsocketopen’;

    and the buddypress notification function in admin. It was tested that
    wp_mail( $to, $subject, $message, $headers ) dont sends out any mail.

    To import the messages we are using the bbpress function messages_new_message( $args )
    This works, but all imported messages from the importer are send to the user – again.

    So how can we import the messages without send them out again? Or alternatively
    wich function should be disabled to prevent the mail transport?

    Hope someone can help us out, and thanks in advance.

    Info:

    WP 3.9.2
    BBpress 2.5.4
    BuddyPress 2.0.2

    Rgds,
    ernstl

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

  • shanebp
    Moderator

    @shanebp

    >To import the messages we are using the bbpress function messages_new_message( $args )

    That is a BP function.
    In it, near the bottom, you will see:
    do_action_ref_array( 'messages_message_sent', array( &$message ) );
    That is the hook to send email if the member has that Setting set to Yes.

    The function messages_message_sent is in:
    \buddypress\bp-messages\bp-messages-notifications.php

    So you could use do_action_ref_array hook with a priority < 10 and strip out the recipients.

    Or you could try a remove_action on
    add_action( 'messages_message_sent', 'messages_notification_new_message', 10 );


    ernstl
    Participant

    @ernstl

    @shanebp the mentioned ref array hook works like a charm. Thank you so much driving me crazy 🙂

    To the folks out there: add this to the BBpress bbpress\includes\admin\converter.php

    add_action('messages_message_sent', 'my_prevent_msg_send', 5 );
    
    function my_prevent_msg_send( $args ) {
        
    	unset( $args->recipients );
    
    }

    to prevent that PMS are send on import.

    More about do_action_ref_array hooks here: https://codex.wordpress.org/Function_Reference/do_action_ref_array

    rgds,
    ernstl


    danbp
    Moderator

    @danbp

    hi @ernstl,

    it is a very bad idea to hack a core file. The modification you added will be lost at the next bbpress update.

    https://codex.buddypress.org/developer/action-reference/


    ernstl
    Participant

    @ernstl

    Hi @danbp,

    thats clear to me, but we only need to import all exsisting data into the new bbpress/buddypress environment and are happy when its done ( db has 6gb… ). Will keep the importer safe, and got it in mind. But thx for mention it.

    Rgds,
    ernstl

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘[Resolved] Need a way to import messages without sending them’ is closed to new replies.
Skip to toolbar