BuddyDev

BuddyPress Private Message for Non Logged in Users

In this tutorial for BuddyPress, we will work on two things:-

  • Show private message button on user profile even if the visitor is not logged in
  • When the visitor click on the button, they get redirected to the login page. Once they log in, the visitor will be sent to the send message page with the initial user set as the reciever.

Seeing the action through screenshots:-

1. Non logged in user visiting other user's profile

buddypress-private-message-button-for-non-loggedin-user

2. Clicking on the private message button redirect to WordPress login page(note the redirect url)

login-screen-with-redirect-url

3. As soon as the user logs in, gets redirected to compose message screen

buddypress-send-private-message-screen

Code:-

Here is the code that you can put in your bp-custom.php or in your theme's functions.php

The tutorial is a result of one of our members here (@tizianopitisci) asking me about showing the private message button for BuddyPress users even when the visitor is not logged in. If you found the code helpful, thank him  🙂

4 Responses to BuddyPress Private Message for Non Logged in Users

  • Very greate and useful tutorial. I think this function helps visitors to understand that the website put in connection the users, so they can see this feature unless they have not yet an account.

    • Thank you. Yes, I definitely believe it will be helpful 🙂

  • it´s working to me. thx a lot.