Forum Replies Created

Viewing 8 replies - 1 through 8 (of 8 total)
  • Thread Starter laurenandchris

    (@laurenandchris)

    Hi @webdevmattcrom!

    Thank you for your message, you’re always so helpful – I genuinely appreciate it. I’ve been trying to make the coding work and am having some trouble, when I add it using the My Custom Functions plug in, it comes up with a fatal error. I tried to change the code to be what I want it to say… I just want a simple box that says ‘Your Message:’ on ALL forms. Are you able to provide any further help or insight into what I need to paste into My Custom Functions to make this work? I would be SO grateful for any help.

    Here is the code I was trying to use (it was copied from your documentation, then I changed the text where I thought to have it read ‘Your Message:’

    /** * Custom Form Fields * * @param $form_id */ function give_myprefix_custom_form_fields( $form_id ) { //Only display for a specific form; //Remove “If” statement to display on all forms if ( $form_id == ‘754’ ) { ?> <div id=”give-referral-wrap”> <label class=”give-label” for=”give-referral”><?php _e( ‘Your message:’, ‘give’ ); ?></label> <span class=”give-tooltip icon icon-question” data-tooltip=”<?php _e( ‘Please take a moment to write a personal message’, ‘give’ ) ?>”></span> <textarea class=”give-textarea” name=”give_referral” id=”give-referral”></textarea> </div> <?php }//endif } add_action( ‘give_after_donation_levels’, ‘give_myprefix_custom_form_fields’, 10, 1 ); /** * Validate Custom Field * * @description check for errors without custom fields * * @param $valid_data * @param $data */ function give_myprefix_validate_custom_fields( $valid_data, $data ) { //Check that we’re validating the proper form //Remove if this is a global field if ( $data[‘give-form-id’] !== ‘754’ ) { return; } //Check for a referral data if ( empty( $data[‘give_referral’] ) ) { give_set_error( ‘give_referral’, __( ‘Please take a moment to write a personal message’, ‘give’ ) ); } } add_action( ‘give_checkout_error_checks’, ‘give_myprefix_validate_custom_fields’, 10, 2 ); /** * Add Field to Payment Meta * * @description store the custom field data in the payment meta * * @param $payment_meta * * @return mixed */ function give_myprefix_store_custom_fields( $payment_meta ) { $payment_meta[‘referral’] = isset( $_POST[‘give_referral’] ) ? implode( “n”, array_map( ‘sanitize_text_field’, explode( “n”, $_POST[‘give_referral’] ) ) ) : ”; return $payment_meta; } add_filter( ‘give_payment_meta’, ‘give_myprefix_store_custom_fields’ ); /** * Show Data in Transaction Details * * @description show the custom field(s) on the transaction page * * @param $payment_meta * @param $user_info */ function give_myprefix_purchase_details( $payment_meta, $user_info ) { //uncomment below to see payment_meta array // echo “

    "; // var_dump($payment_meta); // echo "

    “; //Bounce out if no data for this transaction if ( ! isset( $payment_meta[‘referral’] ) ) { return; } ?> <div class=”referral-data”> <label><?php echo __( ‘Referral:’, ‘give’ ); ?></label> <?php echo wpautop( $payment_meta[‘referral’] ); ?> </div> <?php } add_action( ‘give_payment_personal_details_list’, ‘give_myprefix_purchase_details’, 10, 2 );

    Thread Starter laurenandchris

    (@laurenandchris)

    Thank you @webdevmattcrom! You’re so helpful, I really appreciate it. I just went and left a review (five stars, of course!).

    Thread Starter laurenandchris

    (@laurenandchris)

    Hi Devin,

    Sorry… I’m a little confused. The long code I pasted above is what’s in here currently and has worked find to change the wording.

    When I pasted this code below, it then created a fatal error…

    .give-form .give-goal-progress .income {
    font-size: 16px;
    }

    When I also paste in the other text provided to change the email header, it creates a fatal error…

    function my_give_text_switcher( $translations, $text, $domain ) {

    if ( $domain == ‘give’ && $text == ‘Donation Receipt’ ) {
    $translations = __( ‘Receipt’, ‘give’ );
    }

    return $translations;
    }
    add_filter( ‘gettext’, ‘my_give_text_switcher’, 10, 3 );

    I just don’t know what to do! I am pasting in exactly the code provided. Are you able to combine them for me so I can know exactly what to put in my Custom Functions PHP code to achieve all three outcomes?

    I would be so so so grateful for your help, I’ve been struggling with this for a week!

    Thank you!

    Thread Starter laurenandchris

    (@laurenandchris)

    Hi Devin,
    Thank you for your reply! I tried this code and similar to the issue I was having with the other code, when I add it into the Custom Functions plugin, it says “Sorry, but your code causes a “Fatal error”, so it is not applied! Please, check the code and try again.”

    Given this has happened with both codes, I’m thinking I’m doing something wrong.

    Lines 1 – 12 of my Custom Functions PHP code are:

    function my_give_text_switcher( $translations, $text, $domain ) {
    // changes the “Donations” text in multiple places
    if ( $domain == ‘give’ && $text == ‘%1$s of %2$s raised’ ) {
    $translations = __( ‘%1$s of %2$s’, ‘give’ );
    }

    if ( $domain == ‘give’ && $text == ‘Donation Total:’ ) {
    $translations = __( ‘Your Total:’, ‘give’ );
    }
    return $translations;
    }
    add_filter( ‘gettext’, ‘my_give_text_switcher’, 10, 3 );

    When I go to add new code in, do I just add it to the line below? Do I leave any space? Is there anything I have to do when copying this new code into the Custom Functions PHP?

    Thank you!!!

    Thread Starter laurenandchris

    (@laurenandchris)

    Hi Devin, thank you for your help!

    The site isn’t open / it’s closed for viewing while in development… am I able to provide you with the styling info you may need to form the code? Eg. do you need to just know the text size / font of the text I am wanting to match?

    If so, it is Lato, size 13, black color.

    Is this enough info for styling the dollar amount text to match the writing alongside it?

    Thank you so much for your help!!

    Thread Starter laurenandchris

    (@laurenandchris)

    I copied the code exactly and added it to my custom functions PHP code…
    It said the same message, that there was a fatal error and code couldn’t be applied. This is a cut and paste of exactly what I copied… is there something wrong? What else could I please try? Is there some where else I need to cut and paste it into? I really appreciate your help!

    function my_give_text_switcher( $translations, $text, $domain ) {

    if ( $domain == ‘give’ && $text == ‘Donation Receipt’ ) {
    $translations = __( ‘Receipt’, ‘give’ );
    }

    return $translations;
    }
    add_filter( ‘gettext’, ‘my_give_text_switcher’, 10, 3 );

    Thread Starter laurenandchris

    (@laurenandchris)

    When I tried to paste this in it comes up saying: Sorry, but your code causes a “Fatal error”, so it is not applied! Please, check the code and try again.

    Is there another code I could please try?

    Thank you!

    Thread Starter laurenandchris

    (@laurenandchris)

    This worked PERFECTLY! I can’t thank you enough for your help!

    Thank you! Thank you! Thank you! ??

Viewing 8 replies - 1 through 8 (of 8 total)