I finally yielded, and messed up (so to speak) the function messages_screen_compose, adding conditional custom redirects with if else statements like…
`
if(wp_get_referer()){//to check origin of form submission, returns false for self submission
bp_core_redirect(wp_get_referer()); //custom redirect, as this isn’t self submission
} else {
bp_core_redirect( bp_loggedin_user_domain() . $bp->messages->slug . ‘/view/’ . $thread_id . ‘/’ );// this was originally there, for submission from original php file
}
`
As I think the issue is ‘resolved’, for time being, I should document the solution here.
I intended to use buddypress private messaging as feedback form, with various feedback options like Question, Suggestion, Feedback etc. Thus, I created corresponding users (Question, Suggestion, Feedback etc.) who will receive the feedback. The idea is super-elegant from my purpose, as not only the submissions be automatically segregated and stored in database, but responding to the feedbacks would be as simple as responding to PM, all without the hassle of email, spam etc. An added benifit is, users can draw attention to various issues site wide by @mension, like :@question What about this?”
So I tried to imitate the buddypress compose form, and I succeeded, except the redirect problem as described here.
https://buddypress.org/support/topic/create-a-feedback-form-using-buddypress-messaging-functionality/
What I was doing was, creating a duplicate form, but calling the original form action (fooling buddypress 🙂 ). I did so, because, I don’t even know how to submit the copy-pasted form I created, and get the same thing done as the original compose.php was doing when it called itself (self submission).
Anyways, this hack with unforgivable modifications in buddypress files works beautifully. I feel I’ll have to go through the plugin route finally though, as this is make-shift arrangement (but will work as long as I don’t update the buddypress plugin 🙂 ).
Thanks shane for your help.