Hello,
I want to encourage users to tip/donate to other members they like and follow or content creators, so I created a profile group called (BANK DETAILS) which consists of the following profile fields
1. Bank name
2. Account number
3. Stripe address
4. PaypalNow I created a donate page which is meant to display only the Bank details of the receiver and I used the code below to display the button in user profiles
/** * Add custom buttons to profile header */ function np_add_custom_buttons() { if ( ! bp_is_my_profile() ) { return; } $send_tip_button_args = array( 'id' => 'np_send_tip', 'component' => 'members', 'must_be_logged_in' => true, 'block_self' => false, 'link_href' => esc_url( 'https://www.site.com/send-tip/' ), 'link_text' => __( 'Send Tip' ), ); echo bp_get_button( $send_tip_button_args ); } add_action( 'bp_member_header_actions', 'np_add_custom_buttons' );
The problem now is how can I output the Bank details profile information of the recipient in a popup or a shortcode to display the bank details in a page.
The feature will be similar to Twitter tip jar https://techcrunch.com/2021/05/06/twitter-tip-jar-lets-you-pay-people-for-good-tweetin/
But only bank details profile info needs to be displayed.
What do you think about this
Hello Tosin,
Please check the following code:
It allows displaying user data based on profile field group id. Please let me know if it helps or not.
Regards
RaviHello Tosin,
Yes, You have to install the plugin in order to use this shortcode.
On single-user screen you can use shortcodes like:
Replace id with your band detail field group id.
[bp-shortcodes-profile context=display group_id=4]
On the member directory and post screen, you have to provide shortcode attributes dynamically.
Regards
Ravi- This reply was modified 3 years, 3 months ago by Ravi.
Making it dynamic is tricky
Can something similar to this code be used to determine a dynamic url then the username is the url can be picked by the [bp-shortcodes-profile context=display group_id=4] to determine the context of the profile data
function hibuddy_get_send_public_message_url() { $user_id = hibuddy_get_context_user_id(); if ( ! $user_id || $user_id == bp_loggedin_user_id() ) { return; } if ( bp_is_my_profile() || ! is_user_logged_in() ) { return false; } $username = bp_core_get_username( $user_id ); return apply_filters( 'hibuddy_get_send_public_message_url', wp_nonce_url( site_url() . '/news-feed/?r=' . $username ) ); }
Maybe $username of the recipient can be picked [bp-shortcodes-profile context=display group_id=4] so context=username from the url
Thanks
Hello Tosin,
Thank you for sharing the code. Shortcode does provide an attribute name ‘user_id’. Have you tried this?
do_shortcode( '[bp-shortcodes-profile user_id=' . hibuddy_get_context_user_id() . ' group_id=4]' );
Please give it shot and let me know if it helps or not.
Regards
RaviI could not get anything to work, I just got confused with making the send donation link dynamic.
WHAT IM TRYING TO ACHIVE
1. Create a (send-donation) page which contains the shortcode [bp-shortcodes-profile context=display group_id=2]
2. Clicking send donation link in either blog post or single user profile would redirect to (send-donation) page.
3. On this page the potential donor/sender would see the bank details of the receiver determined by(username of post author or user profile)
Hello Tosin,
Check the follwing code I have created for user profile using Nouveau Template pack:
add_filter( 'bp_nouveau_get_members_buttons', function ( $buttons ) { $user_id = bp_displayed_user_id(); $donation_page_link = add_query_arg( array( 'user_id' => $user_id, 'nonce' => wp_create_nonce( 'donate-' . $user_id ), ), get_page_link( 68 ) // Replace by your donation page link. ); $buttons['donation_link'] = array( 'id' => 'donation_link', 'component' => 'members', 'must_be_logged_in' => true, 'link_text' => _x( 'Donate', 'button', 'buddypress' ), 'link_href' => esc_url( $donation_page_link ), ); return $buttons; } ); add_filter( 'the_content', function ( $content ) { // Our donation page link. if ( ! is_page( 68 ) || ! isset( $_GET['user_id'] ) || ! $_GET['nonce'] ) { return $content; } $user = get_user_by( 'id', absint( $_GET['user_id'] ) ); if ( ! $user || ! wp_verify_nonce( $_GET['nonce'], 'donate-' . $user->ID ) ) { return $content; } ob_start(); echo do_shortcode( "[bp-shortcodes-profile user_id={$user->ID} group_id=2]" ); $shortcode_content = ob_get_clean(); return $content . $shortcode_content; } );
Regards
Ravi
You must be logged in to reply to this topic.