Viewing 10 replies - 1 through 10 (of 10 total)
  • Plugin Support Rick Alday

    (@mrdaro)

    Hi @smdstudios,

    You can use this function to display the field data in the donation details page:

    function render_givewp_field_api_fields( $payment_id ) {
    
    	$field_name = give_get_meta( $payment_id, 'guestName', true );
    
    	if ( $field_name ) : ?>
    
    		<div id="<?php echo wpautop( $field_name ); ?>" class="postbox">
    			<!--Replace 'Field Label' with a relevant label. -->
    			<h3 class="handle"><?php esc_html_e( 'Field label', 'give' ); ?></h3>
    			<div class="inside" style="padding-bottom:10px;">
    				<?php echo wpautop( $field_name ); ?>
    			</div>
    		</div>
    
    	<?php endif;
    
    }
    
    add_action( 'give_view_donation_details_billing_after', 'render_givewp_field_api_fields', 10, 1 );

    Hope it helps!

    Thread Starter smdstudios

    (@smdstudios)

    Thank you.

    Just to clarify I can drop the code into my functions file, edit and that is all the code I need?

    Your code didn’t do anything for me so I want to ensure I’m not missing something.

    Same goes for the custom fields I added to my donations page?

    Plugin Support Matheus Martins

    (@matheusfd)

    Hi, @smdstudios.

    Yes, that’s what you’d need to do. If you need assistance implementing custom PHP code on your website we have this guide:

    https://givewp.com/documentation/resources/adding-custom-functions-to-your-wordpress-website/

    Please note that this code snippet is provided as an example of how you can extend GiveWP with code. It’s up to you to implement and customize to your liking. We cannot provide support for custom code on your website, only the code that we create and distribute.

    It’s important that you edit the code though to reflect the custom fields you created.

    Thanks for using GiveWP! Have a great day.

    Thread Starter smdstudios

    (@smdstudios)

    Thank you..I just wanted to make sure that I didn’t need to write any additional code actually to save it to the DB.

    If I can’t get that display function to work, I can manually pull the custom fields from the DB.

    Try something like this:

    function render_givewp_field_api_fields( $payment_id ) {
    
    	$occupation = give_get_meta( $payment_id, 'occupation', true );
    	$employer = give_get_meta( $payment_id, 'occupation', true );
    
    	if ( $occupation ) : ?>
    
    		<div id="<?php echo wpautop( $occupation ); ?>" class="postbox">
    			<!--Replace 'Field Label' with a relevant label. -->
    			<h3 class="handle"><?php esc_html_e( 'Occupation', 'give' ); ?></h3>
    			<div class="inside" style="padding-bottom:10px;">
    				<?php echo wpautop( $occupation ); ?>
    			</div>
    		</div>
    
    	<?php endif;
    
    }
    
    if ( $employer ) : ?>
    
    		<div id="<?php echo wpautop( $employer ); ?>" class="postbox">
    			<!--Replace 'Field Label' with a relevant label. -->
    			<h3 class="handle"><?php esc_html_e( 'Employer', 'give' ); ?></h3>
    			<div class="inside" style="padding-bottom:10px;">
    				<?php echo wpautop( $employer ); ?>
    			</div>
    		</div>
    
    	<?php endif;
    
    }
    
    add_action( 'give_view_donation_details_billing_after', 'render_givewp_field_api_fields', 10, 1 );
    Plugin Support Matheus Martins

    (@matheusfd)

    Hi, @smdstudios.

    Do you still need assistance here? Looking forward to helping you get to the bottom of this!

    Thread Starter smdstudios

    (@smdstudios)

    I still haven’t been able to get the data to appear in the admin section.

    I might just skip that and try and just get the extra fields in a data export. Is there any additional code needed for that?

    Plugin Support Rick Alday

    (@mrdaro)

    Hi @smdstudios,

    I made a quick and dirty video tutorial here that shows you how to add the custom field data to the donation details page and to the export: https://somup.com/c3jT04Ujl9

    Here’s the code I used there:
    https://gist.github.com/rickalday/ac01194ea0a930b5816f41754fa5a148

    If you use the Code Snippets plugin as I did, you don’t need the opening <?php tag in the code.

    Hope it helps!

    Thread Starter smdstudios

    (@smdstudios)

    Thank you! That helped a lot!!

    Plugin Support Matheus Martins

    (@matheusfd)

    Glad to hear that, @smdstudios. @mrdaro is a gem!

    We’re looking to earn more 5-star reviews on our www.ads-software.com page. If you’ve found our support helpful and if you’ve been loving the GiveWP plugin, I’d love to earn a 5-star review from you!
    ?
    ?WordPress: https://www.ads-software.com/support/view/plugin-reviews/give

    Reviews help other organizations see how much value and success other GiveWP users get from our products. I truly appreciate your time! (and you’d totally make my day ??).

    Thanks for using GiveWP! Have a great day.

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘Custom Fields Data’ is closed to new replies.