How to add additional attachment fields to the Payout Request Form

Hello HivePress Team and Community,

I’m currently working on setting up my platform using HivePress, and I have a specific requirement that I hope to get some guidance on.

I need to add two additional attachment fields to the “Payout” request form for advertisers when they wish to withdraw their earnings from the platform. These fields are crucial for my payment process as I use Stripe instead of PayPal. Here are the fields I’d like to add:

  1. Identity Card (Front and Back)
  2. Bank Account Details (often referred to as RIB in French)

Having these two pieces of information is paramount for me to ensure a smooth and secure payment process for my advertisers.

Could you please guide me on how to implement these additional fields or if there’s a feature in the pipeline that might cater to this need?

Thank you in advance for your assistance and guidance.

Best regards,

Hi,

Please check this topic Add new payout fields.

Hi Andrii !

Thank you for your response. I’ve reviewed the code you provided from the topic “Add new payout fields.” However, it seems that the code you shared doesn’t include the attachment fields, which is what I’m specifically looking for.

I’ve previously tried the following code to add attachment fields for an identity card and a bank document (RIB):

add_filter(
    'hivepress/v1/forms/payout_request',
    function( $form ) {
        // Field for the Identity Card (Front and Back)
        $form['fields']['identity_card'] = [
            'label'    => 'Identity Card (Front & Back)',
            'type'     => 'attachment',
            '_order'   => '10',
            'required' => true,
        ];

        // Field for the RIB
        $form['fields']['rib'] = [
            'label'    => 'RIB',
            'type'     => 'attachment',
            '_order'   => '11',
            'required' => true,
        ];

        return $form;
    },
    1000
);

However, after implementing this code with the Code Snippets plugin, I haven’t observed any changes on the platform. Could you please guide me on how to properly add attachment fields to the payout request form? I’d appreciate any assistance you can provide.

Thank you in advance.

Hi,

Please note, there’s no simple code snippet for adding, validating, saving and displaying custom payout fields in the current version, please consider using vendor attributes - users will have to set them once, and they will not be added to the Add Listings form (they will be in the Complete Profile form, and it appears only if some fields are still not set for a vendor).

Hi Andrii !

Ok, I understand - thank you for your precisions ! :slight_smile:

One last question, what is the hook I need to use for the Complete Profil form ?

I tried this one with this entire code but the fields don’t appear :

// Validation des champs "attachment" pour le formulaire "Compléter le profil"

add_filter(
    'hivepress/v1/forms/user_update/errors',
    function( $errors, $form ) {
        if(!empty($errors)){
            return $errors;
        }

        $user = $form->get_model();

        // Vérification de la Carte d'identité (Recto Verso)
        if ( $user && ! $user->get_identity_card() ) {
            $errors[] = 'Veuillez télécharger la Carte d\'identité (Recto Verso).';
        }

        // Vérification du RIB
        if ( $user && ! $user->get_rib() ) {
            $errors[] = 'Veuillez télécharger le RIB.';
        }

        return $errors;
    },
    100,
    2
);
// Modification du formulaire "Compléter le profil" pour ajouter les champs "attachment"
add_filter(
    'hivepress/v1/forms/user_update',
    function( $form ) {
        // Champ pour la Carte d'identité (Recto Verso)
        $form['fields']['identity_card'] = [
            'label'    => 'Carte identité (Recto Verso)',
            'type'     => 'attachment',
            'required' => true,
        ];

        // Champ pour le RIB
        $form['fields']['rib'] = [
            'label'    => 'RIB',
            'type'     => 'attachment',
            'required' => true,
        ];

        return $form;
    },
    1000
);

// Mise à jour des champs du modèle "Vendor" pour les rendre obligatoires
add_filter(
    'hivepress/v1/models/vendor/fields',
    function($fields){
        // Champ pour la Carte d'identité (Recto Verso)
        $fields['identity_card'] = [
            'type'     => 'attachment',
            'required' => true,
        ];

        // Champ pour le RIB
        $fields['rib'] = [
            'type'     => 'attachment',
            'required' => true,
        ];

        return $fields;
    },
    1000
);

And when I want to validate the complete profil form, there are thoses error messages :

Please try to change the type attachment on attachment_upload for the model and form fields.

Hi Yevhen ! Thanks ! Now I see the attachment_upload field !

But where can I find all the attachments that users upload through the ‘Complete Form’?

Hi,

These files can be found on the backend side in WP Dashboard > Vendors (Hosts).

Hi Andri,

First of all I apologize for the response delay.

Can you be more specific when you say “backend side in WP Dashboard > Vendors (Hosts).” please ?

When I’m in the Vendors section, in the WP backend, I find no place where the attachments are settled.

Hi,

Yes, in your case, this tab is called Annonceurs (because you have the French language in the admin panel), and by opening any vendor who has already uploaded a file, you will be able to find the file they added.

Hello Andrii ! Thanks for your answer !

There are no files in the ‘Vendors’ section because I am unable to upload a file directly from my profile completion form. When I try to upload a file, I can select a file from my computer, but once I’ve ‘opened’ it, there is no visual confirmation indicating that my file upload has been successfully processed. Moreover, when I try to validate my form by pressing the ‘Save my informations’ button, the error message I set for when no file is uploaded appears; ‘Please upload your RIB.’




Could you please guide me on how to resolve this issue, or let me know if there is an error in the code I added using the ‘Code Snippets’ plugin:

add_filter(
    'hivepress/v1/forms/user_update/errors',
    function( $errors, $form ) {
        if(!empty($errors)){
            return $errors;
        }

        $user = $form->get_model();

        // RIB Verification
        if ( $user && ! $user->get_rib() ) {
            $errors[] = 'Please upload your RIB.';
        }

        return $errors;
    },
    100,
    2
);

add_filter(
    'hivepress/v1/forms/user_update',
    function( $form ) {
        // Field for RIB
        $form['fields']['rib'] = [
            'label'    => 'RIB',
            'type'     => 'attachment_upload',
            'required' => true,
        ];

        return $form;
    },
    1000
);

add_filter(
    'hivepress/v1/models/vendor/fields',
    function($fields){      

        // Field for RIB
        $fields['rib'] = [
            'type'     => 'attachment_upload',
            'required' => true,
        ];

        return $fields;
    },
    1000
);

Thank you for your assistance !
Best Regards !

Hi,

I recommend you remove this PHP snippet and add this attribute using vendor attributes, please check this doc: How to add vendor profile fields - HivePress Help Center. Then everything should work and load correctly. If the standard attachment attribute doesn’t work for you, then let me know and we’ll try to help with a PHP snippet.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.