checkbox field at seller registration

We're shifting our Forum based support to a more dedicated support system!

We'll be closing our Forum support from 10th June, 2020 and move to Email Support assistance.

  • If you are a WCFM premium add-ons user, contact us- here
  • Want to know more before buying our add-ons? Send Pre sale queries- here
  • If you are a WCFM free user, please open a support ticket at WordPress.org
  • For WCFM App related queries, reach us- here
From now the forum will be read-only!

Multi Vendor Marketplace Plugin | WCFM Marketplace Forums WCFM – Membership checkbox field at seller registration

Viewing 4 reply threads
  • Author
    Posts
    • #103152
      thiemann.k
      Participant

      Hey Community,

      i want to use an checkbox at a seller registration step.

      Unfortunately, I really don’t know what the job is called.

      vendor-membership/?vmstep=registration

      Thanks, Karsten

      P.S: here is an excerpt from my snippet

      // Display a custom checkbox in My Account > Account details
      add_action( 'woocommerce_register_form', 'add_account_newsletter_checkbox_field' );
      add_action( 'woocommerce_edit_account_form', 'add_account_newsletter_checkbox_field' );
      ADD_ACTION( 'WCLOVERS VMSTEP=REGISTRATION', 'add_account_newsletter_checkbox_field' );
      function add_account_newsletter_checkbox_field() {
          woocommerce_form_field( 'receive_newsletter', array(
              'type'  => 'checkbox',
              'class' => array('form-row-wide'),
              'label' => __( 'Möchtest Du unseren Newsletter?', 'woocommerce' ),
              'clear' => true,
          ), get_user_meta(get_current_user_id(), 'receive_newsletter', true ) );
      
      }
    • #103204

      Hi,

      No need to use custom coding for this. You can go to store-manager->Settings->Vendor Registration and create custom fields ( checkbox ) under “Registration Form Custom Fields”.

      Thanks,

    • #103232
      thiemann.k
      Participant

      Hey Molay Das, thanks for your answer! Thats really simple…

      I totally forgot about this function ..

      but the problem I still have is that I can’t get Mailpoet involved there …
      a checkbox yes, but not in combination with our newsletter plugin

      Thanks, Karsten

    • #103335
      thiemann.k
      Participant

      the checkbox for the newsletter is displayed correctly on the standard register page (/wp-signup.php).
      Image: https://ibb.co/b368hVs

      The checkbox is active in the MailPoet settings.
      Image: https://ibb.co/DVdQ47z

      But unfortunately I don’t get this implemented in the registry by WcfM

      This is the original code from mailpoet/lib/subscription/registration.php

      <?php
      namespace MailPoet\Subscription;
      use MailPoet\Settings\SettingsController;
      use MailPoet\Subscribers\SubscriberActions;
      use MailPoet\WP\Functions as WPFunctions;
      
      class Registration {
      
        /** @var SettingsController */
        private $settings;
      
        /** @var SubscriberActions */
        private $subscriber_actions;
      
        function __construct(
          SettingsController $settings,
          SubscriberActions $subscriber_actions
        ) {
          $this->settings = $settings;
          $this->subscriber_actions = $subscriber_actions;
        }
      
        function extendForm() {
          $label = $this->settings->get(
            'subscribe.on_register.label',
            WPFunctions::get()->__('Yes, please add me to your mailing list.', 'mailpoet')
          );
      
          print '<p class="registration-form-mailpoet">
            <label for="mailpoet_subscribe_on_register">
              <input
                type="checkbox"
                id="mailpoet_subscribe_on_register"
                value="1"
                name="mailpoet[subscribe_on_register]"
              />&nbsp;' . esc_attr($label) . '
            </label>
          </p>';
        }
      
        function onMultiSiteRegister($result) {
          if (empty($result['errors']->errors)) {
            if (
              isset($_POST['mailpoet']['subscribe_on_register'])
              && (bool)$_POST['mailpoet']['subscribe_on_register'] === true
            ) {
              $this->subscribeNewUser(
                $result['user_name'],
                $result['user_email']
              );
            }
          }
          return $result;
        }
      
        function onRegister(
          $errors,
          $user_login,
          $user_email = null
        ) {
          if (
            empty($errors->errors)
            && isset($_POST['mailpoet']['subscribe_on_register'])
            && (bool)$_POST['mailpoet']['subscribe_on_register'] === true
          ) {
            $this->subscribeNewUser(
              $user_login,
              $user_email
            );
          }
          return $errors;
        }
      
        private function subscribeNewUser($name, $email) {
          $segment_ids = $this->settings->get(
            'subscribe.on_register.segments',
            []
          );
      
          if (!empty($segment_ids)) {
            $this->subscriber_actions->subscribe(
              [
                'email' => $email,
                'first_name' => $name,
              ],
              $segment_ids
            );
          }
        }
      }
      

      I tried to use parts of it … the checkbox is shown, but it doesn’t work.

      // Display a custom checkbox in My Account > Account details
      add_action( 'woocommerce_register_form', 'add_account_newsletter_checkbox_field' );
      add_action( 'woocommerce_edit_account_form', 'add_account_newsletter_checkbox_field' );
        function add_account_newsletter_checkbox_field() {
      
          print '<p class="registration-form-mailpoet">
            <label for="mailpoet_subscribe_on_register">
              <input
                type="checkbox"
                id="mailpoet_subscribe_on_register"
                value="1"
                name="mailpoet[subscribe_on_register]"
              />&nbsp;' . esc_attr($label) . '
            </label>
          </p>';
    • #103412

      Hi,

      The section which I explained is only for adding custom fields in vendor registration form but if you wish to implement any newsletter to it then it will require paid custom development.
      Please contact us here for the purpose – https://wclovers.com/woocommerce-multivendor-customization/

      Thanks,

Viewing 4 reply threads
  • You must be logged in to reply to this topic.