Skip Navigation

[Gelöst] Slider of users with vendors role

This support ticket is created vor 6 Jahren, 6 Monaten. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Heute stehen keine Supporter zur Arbeit im Werkzeugsatz-Forum zur Verfügung. Sie können gern Tickets erstellen, die wir bearbeiten werden, sobald wir online sind. Vielen Dank für Ihr Verständnis.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Hong_Kong (GMT+08:00)

Dieses Thema enthält 1 Antwort, hat 1 Stimme.

Zuletzt aktualisiert von abdullahA-6 vor 6 Jahren, 6 Monaten.

Assistiert von: Luo Yang.

Author
Artikel
#907355
user custom fields.JPG

Hi,

I am trying to create a slider that loop through users with the role of vendors, I am using a third party plugin for the vendors, and I registered all the user custom fields with types, as in the picture, except I am trying to create a link to the vendors page.
I added the following wp-config :

// get the store url
function get_store_url(){

            global $authordata;
            $store_info = dokan_get_store_info( $authordata->ID );
            if ( !empty( $store_info['store_name'] ) ) { 
                
                $vendor_link = dokan_get_store_url( $authordata->ID ); 
                
              return $vendor_link; 
        } 
}

and from the toolset setting I registered the short code, and added the short code in the slider, the slider is working except all the links direct to the admin store page.
I need each link to direct to the current vendor in the slider loop.

any help is appreciated

thanks

#907829

I managed to solve this issue, I hope this could help someone else later:

in child theme function.php add the short-code that takes id=" " as an attribute :

function get_store_url($atts){

    $a = shortcode_atts(
        array(
          'id' => '1',
       ), 
        $atts );
    $seller_id  = get_user_by( 'id', $a['id'] );
    $vendor = dokan()->vendor->get( $seller_id );
            
                return  $vendor->get_shop_url();
}
add_shortcode( 'store_vendor_url', 'get_store_url' );

then from toolset> settings>front-end content>3rd party shortcode add :

[store_vendor_url]

in the slider or any view you may use :

[store_vendor_url id="5"]

for vendor with id 5

or for the current vendor in the slider loop:

[store_vendor_url id="[wpv-user field='ID']"]
or 
<a class="btn btn-primary" target="_blank" href="[store_vendor_url id="[wpv-user field='ID']"]"> Visit Store </a> </div>

(quotation format is really important otherwise won't work)

thanks