Shortcode to display Vendors Current Membership
-
Hi,
I have looked through the documentation here : https://docs.wclovers.com/shortcode
but cannot find a shortcode for the logged in vendors membership type.I want to display [logged in-vendors-current-membership] by shortcode on another page of the site ?
2. How to redirect vendor to woocommerce account page instead of frontend manager on login ?
Thanks
The page I need help with: [log in to see the link]
-
I want to display [logged in-vendors-current-membership] by shortcode on another page of the site ?
– Kindly use this shortcode –
[wcfm_store_info data="wcfm_membership"]
2. How to redirect vendor to woocommerce account page instead of frontend manager on login ?
– Use this snippet –
add_filter( 'wcfm_login_redirect', function( $redirect_to, $user ) { if ( in_array( 'wcfm_vendor', $user->roles ) ) { $redirect_to = get_permalink( wc_get_page_id( 'myaccount' ) ); } return $redirect_to; }, 50, 2 );
Add custom code(s) to your child theme’s functions.php
In case you do not have child theme then add those using this plugin – https://wordpress.org/plugins/code-snippets/Hi,
This shortcode [wcfm_store_info data=”wcfm_membership”]
does not display anything. It is blank ! I created a new WordPress page cleared cache but nothing..
To be clear I want to display the ‘membership table’ of current vendor/users membership. This is really important for my site.This shortcode works from vendor’s store and product page.
If you want to use this at any pages then have to add store vendor user id as attribute.
Then shortcode will be like this =
[wcfm_store_info data="wcfm_membership" id="ADD STORE VENDOR USER ID HERE"]
This shortcode on vendor store sidebar only shows a random 4 digit number ? [wcfm_store_info data=”wcfm_membership”]
Please can you add this function in an update to show shortcode of vendor membership table anywhere in the site ?
Infact both shortcodes do not display anything..
Here is a screenshot of this shortcode
[wcfm_store_info data=”wcfm_membership”]
you provided in the vendor sidebar showing it does not display anything but numbers ??Btw! There are spelling mistakes in your wcfm marketplace plugin ! I think you should check your code in
class.wcfmvm-shortcode.php
There are spelling mistakes in your wcfm marketplace plugin ! I think you should check your code in class.wcfmvm-shortcode.php
– Thanks for this.
you provided in the vendor sidebar showing it does not display anything but numbers ??
– Yeah, it’s showing membership id. Now add this snippet to your site, it will show membership name there –
add_filter( 'wcfmmp_additional_store_info', function( $data_value, $data_info, $store_id ) { if( $data_info == 'wcfm_membership' ) { if( $data_value && function_exists( 'wcfm_is_valid_membership' ) && wcfm_is_valid_membership( $data_value ) ) { $data_value = get_the_title( $data_value ); } } return $data_value; }, 50, 3 );
You may add icon and label to the shortcode as well, like this –
[wcfm_store_info data="wcfm_membership" id="ADD STORE VENDOR USER ID HERE" label="Membership" icon="user-o"]
Hi thanks,
but can you please provide the shortcode or php to show the vendors membership plan and details as a table as shown in frontend manager store vendors tab here ? https://prnt.sc/u8nz1vThe Admin cannot be expected to enter the “id” for each vendor , the shortcode must pull this data automatically !
2. Or please point me to the exact location in wp-content / wcfm.membership plugin to where this table is and I will try make it into a shortcode.
Thanks
The Admin cannot be expected to enter the “id” for each vendor , the shortcode must pull this data automatically !
– Right, but there no specific shortcode to show vendor’s membership as it’s a internal thing between Admin and Vendors.
[wcfm_store_info] is special type of shortcode which we can use to show vendor’s any information. But sometimes we have to process data before display as this shortcode returns raw data as saved in database.
Please use this revised code, it will show membership plan details. Though I have not added any style here.
add_filter( 'wcfmmp_additional_store_info', function( $data_value, $data_info, $store_id ) { if( $data_info == 'wcfm_membership' ) { if( $data_value && function_exists( 'wcfm_is_valid_membership' ) && wcfm_is_valid_membership( $data_value ) ) { $data_value = get_the_title( $data_value ); $data_value .= "<br />" . wcfm_membership_features_table( $data_value ); } } return $data_value; }, 50, 3 );
Hi,
Thanks for this but looking at it now this table is not suitable.
NB! I just need a code to display logged in vendors membership only. It must be global but instead of example: id= “1” it should be “logged in vendor”
[wcfm_store_info data="wcfm_membership" label="Membership" id="logged in vendor" icon="rh-icon rhi-user"]
Ok, where you have added this short code?
You may fetch current logged in user’s id using this function – https://developer.wordpress.org/reference/functions/get_current_user_id/
You may check whether a logged in user is vendor or not using this function –
wcfm_is_vendor()
rh-icon rhi-user – WCFM does not support this icon set, only support Font Awesome icons.
Hi,
Please can you update this current user get_current_user_id()function to the full wcfm php code you provided so I don’t crash my site.[wcfm_store_info data=”wcfm_membership” label=”Membership” id=”current_user” icon=”fa-user”]
I only want to display the membership plan of logged in vendor. I display it on woo account page in a custom tab.
Thanks
Hi,
please kindly confirm if this is the code using get_current_user_id ? If not please update it for me.
I am using this shortcode :[wcfm_store_info data="wcfm_membership" id="0" label="Membership" icon="fa fa-user"]
add_filter( 'wcfmmp_additional_store_info', function( $data_value, $data_info, $store_id ) { if( $data_info == 'wcfm_membership' ) { if( $data_value && function_exists( 'wcfm_is_valid_membership' ) && wcfm_is_valid_membership( $data_value ) ) { $data_value = get_the_title( $data_value ); function get_current_user_id() { if ( ! function_exists( 'wp_get_current_user' ) ) { return 0; } $user = wcfm_is_vendor(); return ( isset( $user->ID ) ? (int) $user->ID : 0 ); } } } return $data_value; }, 50, 3 );
NO, this code is not right, use this –
add_filter( 'wcfmmp_additional_store_info', function( $data_value, $data_info, $store_id ) { $data_value = ''; if( $data_info == 'wcfm_membership' ) { if( wcfm_is_vendor() ) { $store_id = apply_filters( 'wcfm_current_vendor_id', get_current_user_id() ); $data_value = get_user_meta( $store_id, 'wcfm_membership', true ); if( $data_value && function_exists( 'wcfm_is_valid_membership' ) && wcfm_is_valid_membership( $data_value ) ) { $data_value = get_the_title( $data_value ); $data_value .= "<br />" . wcfm_membership_features_table( $data_value ); } } } return $data_value; }, 50, 3 );
Also do not use “0” as shortcode “id” attribute. Use some large positive number.
- This reply was modified 3 years, 7 months ago by WC Lovers.
Hi,
Thanks very much, it seems to be working now for logged in vendor.
Can you tell me what this line is? Can this line be removed or can another attribute be put there ?
$data_value .= "<br />" . wcfm_membership_features_table( $data_value );
}
- The topic ‘Shortcode to display Vendors Current Membership’ is closed to new replies.