BuddyDev

Search

Replies

  • Participant
    Level: Guru
    Posts: 900
    Tosin on in reply to: Share post as activity suggestions #40331

    Gentle reminder sir, thanks

  • Participant
    Level: Guru
    Posts: 900
    Tosin on in reply to: buddypress better search github #40258

    OK thanks but do you have an alternative search plugin to recommend which works with buddypress

    SearchWP https://searchwp.com/ does not work with buddypress

  • Participant
    Level: Guru
    Posts: 900
    Tosin on in reply to: Donation feature for buddypress #40238

    thats exactly my point see image https://ibb.co/HNZrFBy

    Sorry for the trouble

    This is my code

    
     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;
    	}
    
    	$bank_name               = xprofile_get_field_data( 3217, $user->ID );
    	$account_number          = xprofile_get_field_data( 3218, $user->ID );
    	$account_name            = xprofile_get_field_data( 3219, $user->ID );
    	$paystack_url            = xprofile_get_field_data( 3220, $user->ID );
    	$crypto_currency_name    = xprofile_get_field_data( 4447, $user->ID );
    	$crypto_currency_address = xprofile_get_field_data( 4446, $user->ID );
    
    	$missing_details = array();
    
    	// Replace field id with your one mandatory for donation. If empty return your message.
    	if ( empty( $bank_name ) ) {
    		$missing_details[] = __( 'Bank name has not been provided' );
    	}
    	if ( empty( $account_number ) ) {
    		$missing_details[] = __( 'Account number has not been provided' );
    	}
    	if ( empty( $account_name ) ) {
    		$missing_details[] = __( 'Account name has not been provided' );
    	}
    	if ( empty( $paystack_url ) ) {
    		$missing_details[] = __( 'Paystack URL has not been provided' );
    	}
    	if ( empty( $crypto_currency_name ) ) {
    		$missing_details[] = __( 'Cryptocurrency name has not been provided' );
    	}
    	if ( empty( $crypto_currency_address ) ) {
    		$missing_details[] = __( 'Cryptocurrency address has not been provided' );
    	}
    
    	$render_shortcode = false;
    
    	if ( $bank_name || $account_number || $account_name || $paystack_url || $crypto_currency_name || $crypto_currency_address ) {
    		$render_shortcode = true;
    	}
    
    	if ( ! $render_shortcode ) {
    		return $content . __( 'This member has not provided any payment details, the following payment details are missing: ' ) . join( ' & ', $missing_details );
    	}
    
    	ob_start();
    
    	// Replace group_id to your group id.
    	echo do_shortcode( "[bpsc-user-avatar user_id={$user->ID}]" );
    	echo do_shortcode( "[bpsc-user-display-name user_id={$user->ID}]" );
    	echo do_shortcode( "[bp-shortcodes-profile user_id={$user->ID} group_id=2]" );
    
    	$shortcode_content = ob_get_clean();
    
    	return $content . $shortcode_content;
    } );
     
    
  • Participant
    Level: Guru
    Posts: 900
    Tosin on in reply to: Donation feature for buddypress #40228

    I have tested this several times now this section below does not display any text for empty fields

    return $content . __( ‘Following details are missing’ ) . join( ‘ & ‘, $missing_details );

  • Participant
    Level: Guru
    Posts: 900
    Tosin on in reply to: Donation feature for buddypress #40187

    some users provided only their bank name and account number data without providing paystack and cryptocurrency details but the available data/info is not being displayed

    The code you provided is ok

    NOW
    If at least one of the xprofile payment fields data is available do not show any of the $missing_details text and output/display only the available profile data/info.

  • Participant
    Level: Guru
    Posts: 900
    Tosin on in reply to: Donation feature for buddypress #40160

    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.

  • Participant
    Level: Guru
    Posts: 900
    Tosin on in reply to: Donation feature for buddypress #40147

    I tried modifying the code but it wasn’t ok
    see modified code something is wrong

     add_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;
    } ); 
  • Participant
    Level: Guru
    Posts: 900
    Tosin on in reply to: Donation feature for buddypress #40118

    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

  • Participant
    Level: Guru
    Posts: 900
    Tosin on in reply to: Donation feature for buddypress #40093

    thanks but im using legacy template not nouveau template

  • Participant
    Level: Guru
    Posts: 900
    Tosin on in reply to: Branded login and BP Rewrites #40083

    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