Deprecated: The WP_User->id function was called with an argument

MultivendorX

Resolved
Viewing 6 reply threads
  • Author
    Posts
    • #216676
      l.gan
      Participant

      Hello, thanks for your support. I recently updated and see this error in the debug. Could you help me with the code, I don’t quite understand what I should fix, because Your team previously provided me with this code.
      I get an error:
      Deprecated: The WP_User->id function was called with an argument that is deprecated since version 2.1.0! Use WP_User->ID. in /wp-includes/functions.php on line 6031

      //code that causes an error. Output in the product tab.
      <?php
      /*$vendor = get_userdata(get_the_author_meta(‘ID’));
      $vendor_dni_vozv_vend = get_user_meta($vendor->id, ‘_dni_vozv_vend’, true );
      if ( $vendor_dni_vozv_vend ) {
      if ( $vendor_dni_vozv_vend ) {
      echo ‘<span class=”grtxt”>’
      .’free return  ‘
      .'</span>’
      .'<div class=”dnivozvvend”>’ . $vendor_dni_vozv_vend
      . ‘ day.’
      . ‘</div>’;
      } else {
      echo ”;
      }
      echo ”;
      }
      ?>

      code into PHP functionality.
      add_action( ‘mvx_after_shop_front’, ‘extra_setting_fields’ );
      /*form for vendor dashboard set field*/
      function extra_setting_fields() {
      global $MVX;
      $vendor_id = get_current_vendor_id();
      $dni_vozv_vend = ”;
      $dni_vozv_vend = get_user_meta($vendor_id, ‘_dni_vozv_vend’, true) ? get_user_meta($vendor_id, ‘_dni_vozv_vend’, true) : $dni_vozv_vend;
      ?>
      <div class=”panel panel-default panel-outer-heading”>
      <div class=”panel-heading d-flex”>
      <h3><?php _e(‘Return of goods’, ‘multivendorx’); ?></h3>
      </div>
      <div class=”panel-body panel-content-padding form-horizontal”>
      <div class=”mvx_media_block”>
      <div class=”form-group”>
      <label class=”control-label col-sm-3 col-md-3″><?php _e(‘How many days after setting the status as “Completed” can the buyer return the product: (For example: 14 days)’, ‘ multivendorx’); ?></label>
      <div class=”col-md-6 col-sm-9″>
      <input type=”text” name=”dni_vozv_vend” class=”form-control” value= “<?php echo $dni_vozv_vend; ?>” >
      </div>
      </div>
      </div>
      </div>
      </div>
      <?php
      }

      Thank you

    • #216709

      @l.gan Sorry to hear that you have faced an issue on your end. But it is really difficult for our support team to check your custom code line by line.
      Our team predicted that you are getting the deprecated issue because of the following line in your code –

      
      /*$vendor = get_userdata(get_the_author_meta(‘ID’));
      
      Copy

      We would suggest you replace the above line with the below one as the function has been updated from wordpress’s end. You can go through this doc https://developer.wordpress.org/reference/functions/get_userdata/ to know why the function has been updated by WordPress –

      
      get_userdata(get_the_author_meta('ID'))->ID;
      
      Copy
    • #216726
      l.gan
      Participant

      Thank you for your help.

      Could you check (this is not related to my custom code).

      I don’t use the vendor sidebar from the MultivendoX plugin, I use the store sidebar for the vendor page.

      In order to display the coupons provided by the vendor, on the vendor’s store page I added a widget to the sidebar of the store to display coupons from the MultivendoX plugin.

      Everything is ok on the vendor’s store page. (widget is displayed, no errors)
      On the product catalog page (site.com/catalog) I see a message in the place where the coupon display widget is located (the widget itself is not displayed – that’s ok)

      Error text:

      Warning: Undefined property: WP_Post_Type::$term_id in public_html/wp-content/plugins/dc-woocommerce-multi-vendor/includes/mvx-core-functions.php on line 4206
      Copy
    • #216743

      We are able to recreate this on our end. Our team is looking into this. We will add a fix for this soon and keep you posted regarding the same.
      You can keep track of the issue from here https://github.com/multivendorx/MultiVendorX/issues/644.

    • #216748
      This reply has been marked as private.
      • #216966
        l.gan
        Participant

        Thank you

    • #216983

      You are welcome.

      Let us know if you need any further assistance.

    • #218861

      It’s been long and we have not heard back from you. We are closing this thread. If you need help or face issue in future please create a new support ticket.

Viewing 6 reply threads

The topic ‘Deprecated: The WP_User->id function was called with an argument’ is closed to new replies.