Replies
NOTE: all the bank profile data are separate single input text fields
The issue is
1. IF a user has added bank name, account number and account name without adding remaining paystack and cryptocurrency data
2. After clicking donate button and (send-donate) page loads the available bank name, account number and account name is not displayed instead, only the text (Bank name has not been provided) is displayed for all 6 profile data fields.If only one profile data field is empty or not added while some are added, the added/available profile fields are not displayed. One missing profile data prevents other legitimate/available profile field data from being displayed.
On page load, Both available profile field data should be displayed while
Non available profile data should echo/output their corresponding statement e.g Account number has not been provided.I tried modifying the code but it wasn’t ok
see modified code something is wrongadd_action( 'bp_member_header_actions', function () { $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( 36918 ) // Replace by your donation page link. ); $r = array( 'id' => 'donation_link', 'component' => 'members', 'must_be_logged_in' => true, 'link_text' => _x( 'Send Money', 'button', 'buddypress' ), 'link_href' => esc_url( $donation_page_link ), ); echo bp_get_button( $r ); } ); add_filter( 'the_content', function ( $content ) { // Our donation page link. if ( ! is_page( 36918 ) || ! 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; } // Replace field id with your one mandatory for donation. If empty return your message. if ( empty( xprofile_get_field_data( 3217, $user->ID ) ) ) { return $content . __( 'Bank name has not been provided' ); } if ( empty( xprofile_get_field_data( 3218, $user->ID ) ) ) { return $content . __( 'Account number has not been provided' ); } if ( empty( xprofile_get_field_data( 3219, $user->ID ) ) ) { return $content . __( 'Account name has not been provided' ); } if ( empty( xprofile_get_field_data( 3220, $user->ID ) ) ) { return $content . __( 'Paystack URL has not been provided' ); } if ( empty( xprofile_get_field_data( 4447, $user->ID ) ) ) { return $content . __( 'Cryptocurrency name has not been provided' ); } if ( empty( xprofile_get_field_data( 4446, $user->ID ) ) ) { return $content . __( 'Cryptocurrency address has not been provided' ); } ob_start(); // Replace group_id to your group id. echo do_shortcode( "[bpsc-user-avatar user_id={$user->ID} group_id=2]" ); echo do_shortcode( "[bpsc-user-display-name user_id={$user->ID} group_id=2]" ); echo do_shortcode( "[bp-shortcodes-profile user_id={$user->ID} group_id=2]" ); $shortcode_content = ob_get_clean(); return $content . $shortcode_content; } );Ravi you are God sent thanks the code worked perfectly.
The only thing missing now is if a user has not added his bank account and a potential donor clicks the donate button, the (send-donation) page returns an empty or blank page.
It would be better to echo the shortcode only when a valid profile data is available for output
otherwise this statement should be echo in the page.(This member has not updated his/her bank details)
EXAMPLE
1.echo do_shortcode( “[bp-shortcodes-profile user_id={$user->ID} group_id=2]” );
2. If no profile data is available then
3. echo the statement (This member has not updated his/her bank details)Thanks
thanks but im using legacy template not nouveau template
Oh thats wonderful do you know if this feature is being planned to be added to buddypress core or it will remain a standalone plugin.
Thanks
I think you misunderstood me what im trying to say is while bp rewrites is activated the pages section in buddypress settings is totally disabled so its no longer possible to assign pages for branded login plugin.
BP REWRITES plugin removes the pages setting in buddypress and replaces it with a new slug management section.
Now in this slug management section there are not options for branded login.
You might need to activate the BP rewrite plugin and navigate to buddypress settings.
I 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)
I just tested it now but branded login page directory is not included in the new URL tab for editing slugs
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
Thanks for the feedback
1. Do I install the code as a plugin
2. What is the shortcode text to be applied from the text below/** * Create shortcode */ private function setup() { add_shortcode( 'bp-shortcodes-profile', array( $this, 'shortcode' ) ); }