Hello,
Please how can I get this code to work for public message instead of private messages
function bpfr_message_shortcode() { $username = bp_core_get_username( $user_id ); $message = 'Login to message this author !'; if( is_user_logged_in() ) { return '<a href=" '.wp_nonce_url( bp_loggedin_user_domain() . bp_get_messages_slug() . '/compose/?r=' . $username ) .' class="private-message-to-author">Contact the author</a>'; } else { return $message; } } add_shortcode( 'bp_private_message_link', 'bpfr_message_shortcode' );
Thanks
I found a solution
/** * BuddyPress public message shortcode. */ function bp_public_message_shortcode() { $username = bp_core_get_username( $user_id ); $empty = ''; if( is_user_logged_in() && bp_loggedin_user_id() != get_the_author_meta( 'ID' ) ) { return '<a class="inner-msg" href=" '.wp_nonce_url( site_url() . '/news-feed/?r=' . $username ) .' ">Shoutout To Author</a>'; } if( bp_loggedin_user_id() ) { return $empty; } else if( !is_user_logged_in() ) { return '<a class="outer-msg" href=" '.esc_url( wp_login_url()) .' ">Login to follow or message this author !</a>'; } } add_shortcode( 'bp_public_message_link', 'bp_public_message_shortcode' );
Hi Tosin,
Thank you for sharing. I am glad you found a solution.Regards
Brajesh
Viewing 4 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic.
This topic is: not resolved