• i was given this snippet below by @ivan which works on my old theme for adding Bank name, bank account number and name on bank account. It works on my old theme but after i bought a more better theme and inserted same snippet on fresh wordpress installation. It did not work at all.
    Find the code below

    Hi there,

    please, try to add this custom code in the functions.php of your active theme:

    add_filter('yith_wcaf_payment_email_required', '__return_false');

    if ( defined( 'YITH_WCAF' ) ) {
    if ( ! function_exists( 'yith_wcaf_get_extra_fields' ) ) {
    function yith_wcaf_get_extra_fields() {
    return array(
    'bank_name' => array(
    'type' => 'text',
    'label' => __('Bank name', 'yith-woocommerce-affiliates'),
    'mandatory' => true,
    ),
    'bank_account_num' => array(
    'type' => 'text',
    'label' => __('Bank account number', 'yith-woocommerce-affiliates'),
    'mandatory' => true,
    ),
    'bank_account_name' => array(
    'type' => 'text',
    'label' => __('Bank account name', 'yith-woocommerce-affiliates'),
    'mandatory' => true,
    ),
    );
    }
    }

    if ( ! function_exists( 'yith_wcaf_add_custom_fields' ) ) {
    function yith_wcaf_add_custom_fields( $user = false ) {
    $yith_wcaf_additional_fields = yith_wcaf_get_extra_fields();

    $user_id = $user instanceof WP_User ? $user->ID : false;
    $user_id = ( ! $user_id && is_user_logged_in() ) ? get_current_user_id() : $user_id;
    $fields = '';
    $admin = doing_action( 'show_user_profile' ) || doing_action( 'edit_user_profile' );

    if ( $admin ) {
    $fields .= "<hr/>
    <h3>Additional Affiliate Fields</h3>
    <table class='form-table'>";
    }

    foreach ( $yith_wcaf_additional_fields as $field => $opts ) {
    if ( $user_id ) {
    $value = get_user_meta( $user_id, 'yith_wcaf_' . $field, true );
    } else {
    $value = ! empty( $_POST[ 'yith_wcaf_' . $field ] ) ? $_POST[ 'yith_wcaf_' . $field ] : '';
    }

    $fields .= $admin ? '<tr><th>' : "<p class='form-row form-row-wide'>";
    $fields .= "<label for='yith_wcaf_" . $field . "'>" . $opts['label'] . ': ' . ( $opts['mandatory'] ? "<span class='required'>*</span>" : '' ) . '</label>';
    $fields .= $admin ? '</th><td>' : '';
    $fields .= "<input type='" . $opts['type'] . "' class='input-text' name='yith_wcaf_" . $field . "' id='yith_wcaf_" . $field . "' value='$value' " . ( $opts['mandatory'] ? 'required' : '' ) . ' />';
    $fields .= $admin ? '</td></tr>' : '</p>';
    }

    if ( $admin ) {
    $fields .= '</table>';
    }

    echo $fields;
    }

    add_action( 'yith_wcaf_register_form', 'yith_wcaf_add_custom_fields' );
    add_action( 'yith_wcaf_settings_form_after_payment_email', 'yith_wcaf_add_custom_fields' );
    add_action( 'show_user_profile', 'yith_wcaf_add_custom_fields', 21, 1 );
    add_action( 'edit_user_profile', 'yith_wcaf_add_custom_fields', 21, 1 );
    }

    if ( ! function_exists( 'yith_wcaf_register_custom_field' ) ) {
    function yith_wcaf_register_custom_field( $param1, $param2 = false ) {
    $yith_wcaf_additional_fields = yith_wcaf_get_extra_fields();

    if ( doing_action( 'yith_wcaf_new_affiliate' ) ) {
    $id = $param1;
    $affiliate = YITH_WCAF_Affiliate_Handler()::get_instance()->get_affiliate_by_id( $id );
    $user_id = $affiliate['user_id'];
    } elseif ( doing_action( 'yith_wcaf_save_affiliate_settings' ) ) {
    $user_id = $param2;
    } elseif ( doing_action( 'personal_options_update' ) || doing_action( 'edit_user_profile_update' ) ) {
    $user_id = $param1;

    if ( ! current_user_can( 'edit_user', $user_id ) ) {
    return false;
    }
    }

    if ( empty( $user_id ) ) {
    return false;
    }

    foreach ( $yith_wcaf_additional_fields as $field => $opts ) {
    if ( isset( $_REQUEST[ 'yith_wcaf_' . $field ] ) ) {
    update_user_meta( $user_id, 'yith_wcaf_' . $field, sanitize_text_field( $_REQUEST[ 'yith_wcaf_' . $field ] ) );
    }
    }

    if( doing_action( 'yith_wcaf_save_affiliate_settings' ) ) {
    return true;
    }

    }

    add_action( 'yith_wcaf_new_affiliate', 'yith_wcaf_register_custom_field', 10, 1 );
    add_action( 'yith_wcaf_save_affiliate_settings', 'yith_wcaf_register_custom_field', 10, 2 );
    add_action( 'personal_options_update', 'yith_wcaf_register_custom_field', 10, 1 );
    add_action( 'edit_user_profile_update', 'yith_wcaf_register_custom_field', 10, 1 );
    }
    }`

Viewing 9 replies - 1 through 9 (of 9 total)
  • Plugin Support Iván Sosa

    (@ivansosa)

    Hi there,

    hope you are doing well! ??

    Can you describe exactly what happens?
    Do not the fields come out?

    Let us know.

    Have a great day!

    Thread Starter metalsunny

    (@metalsunny)

    It shows critical error

    There has been a critical error on this website. Please check your site admin email inbox for instructions.

    • This reply was modified 3 years, 6 months ago by metalsunny.

    Hello there,

    We hope you are doing well!??

    Could you show us which is the error you are receiving on your admin inbox email?

    Have you tried to execute your site with our plugin without that personalized code that my mate gave to you?

    Let us know any news, please.

    Have a nice day!

    Thread Starter metalsunny

    (@metalsunny)

    I have used the code for a theme before.
    But i am now using a new theme now. So when i insert the code. My sites give the error in the link here https://prnt.sc/1rmsewk

    Plugin Support Christian Rodríguez

    (@christianrh)

    Hello there,

    hope you are doing well! ??

    Looks like there is a character at the end that is wrong.
    Can you delete the last character? It’s a quote: `

    Try it out and let us know any news.

    Have a good day!

    Thread Starter metalsunny

    (@metalsunny)

    No more error after i removed to quote. But the bank details i needed from the code did not show up at all,

    Plugin Support Christian Rodríguez

    (@christianrh)

    Hello there,

    hope you are doing well! ??

    Are you logged in?
    Can you try without being logged in?

    Let us know any news.

    Have a good day!

    Thread Starter metalsunny

    (@metalsunny)

    I am not logged in. I tried it on browser with no user login

    Hi there,
    Hope you are doing well!

    Unfortunately, we have tried the code in our local environments and it works. It seems that the only error was the quote that you already deleted.

    Maybe it could help if you give us the link to the topic where our mate Ivan give you that code.

    Also, I suggest you that try the code with another theme in order to see if the problem could come from the theme.

    If you could try the code with only WooCommerce and Affiliates active, it will help you too in order to see where the problem came from.

    You could also give us a screenshot of the Affiliate Dashboard when you are not logged in?

    Please, let us know.

    Have a great day!

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘Help’ is closed to new replies.