If one were to literally read, your example link; the link would probably work better if there were a “members/user name” between “domain name” & “messages”, i.e., domain_name/members/user_name/messages/blah_blah_blah.
This should go without saying, but the “user_name” would be that of the user who intends to send the PM.
Cheers, I get you. But the button I want has to work for any member. In your example, I’d have to dynamically generate the link in the button and suddenly I’m coding instead of just putting in a static link 😀 I just want a button that any user can click to send me a message. Currently I have a button pointing to my profile and then they have to click another one to start the message. I just want one button.
This is untested but you might try ….
domain/members/me/messages/compose/?r=yourusername
@thinlizzie That’s excellent. Thank you so much. I didn’t know about the “me” thing. It works exactly as I wanted.
I’ve done what you want to do like this:
$user_compose_url = get_site_url() . '/members/' . get_user_by('id', get_current_user_id())->user_nicename . '/messages/compose';
/* or when Buddypress 12.0 will be released */
$user_compose_url = bp_loggedin_user_url( bp_members_get_path_chunks( array( bp_get_messages_slug(), 'compose' ) ) );
$url = wp_nonce_url(
add_query_arg(
'r',
get_user_by('id', $user_id)->user_nicename,
$user_compose_url
)
);
This way you’ll have the nonce.
You’ll need to adapt the code to where you want to display the button though.