Home › Forums › WC Vendors Pro Support › putting dashboard into buddypress
NOTICE: We've Moved to a Ticket System for Support
As of August 31, 2017 (12am EST) our support forums will be retired (read-only), and we will be moving to a support ticket system. This will allow us to better organize and answer support requests, and provide a more personalized experience as we assist our customers.
For the time being, we will leave our forums open for reading and learning while we work on creating a more robust Knowledge Base for everyone to use.
If you are a WC Vendors Pro customer please open a support ticket here. If you are a WC Vendors user please open a support ticket on the Wordpress.org forums.
The information on this forum is outdated and in most instances no longer relevant. Please be sure to check our documentation for the most up to date information.
Thank you to all of our customers!
- This topic has 27 replies, 7 voices, and was last updated 7 years, 8 months ago by
Konrad Sroka.
-
AuthorPosts
-
October 12, 2015 at 11:49 pm #10726
Laurie
ParticipantHi,
Im trying to intergrate wc vendors into buddypress.
I’ve created a tab and I’m having great difficulty getting the dashboard to show up within that tab with decent formatting. I was wondering if I could use
<?php echo do_shortcode('[wcv_pro_dashboard]'); ?>
in the profile tab/page I’ve created And then manually set the address of the Pro Dashboard Page. using php to fetch the username and insert it in the profile address. However I’m unsure how and where to return the value. As far as I can understand the function I need to edit is the one below?
Would it be as simple as just forming the web address and returning it.
Any help greatly appreciated.
public static function create_page( $slug, $page_title = '', $page_content = '', $post_parent = 0 ) {
global $wpdb;
$slug = "http://www.redstow.com/members/lauriedugdale/Vendor/"
$page_id = WC_Vendors::$pv_options->get_option( $slug . '_page_id' );
if ( $page_id > 0 && get_post( $page_id ) ) {
return $page_id;
}$page_found = $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM " . $wpdb->posts . " WHERE post_name = %s LIMIT 1;", $slug ) );
if ( $page_found ) {
if ( !$page_id ) {
WC_Vendors::$pv_options->update_option( $slug . '_page_id', $page_found );return $page_found;
}return $page_id;
}$page_data = array(
'post_status' => 'publish',
'post_type' => 'page',
'post_author' => 1,
'post_name' => $slug,
'post_title' => $page_title,
'post_content' => $page_content,
'post_parent' => $post_parent,
'comment_status' => 'closed'
);$page_id = wp_insert_post( $page_data );
WC_Vendors::$pv_options->update_option( $slug . '_page_id', $page_id );
return $page_id;
} //create_page()
October 13, 2015 at 12:00 am #10727WC Vendors Support
ParticipantThe Shortcode isnt going to work. It relies upon a set page for the Dashboard (aka a standard URL’s Permalink) and none of the buttons will work.
What I would suggest, instead, is you add a link to the Pro Dashboard from the BuddyPress menu. There’s functions to add things to the BP menus using the filter “bp_member_options_nav” ( https://codex.buddypress.org/themes/members-navigation-menus/ )
It’s a very simple filter to write, and since it’s so easy, I wrote one just for you right now. Give it a shot.
October 13, 2015 at 8:27 am #10743Laurie
ParticipantHi,
Thanks, will give that a go!
However would it not be possible to put something like the code below into one of the admin functions to provide the link? Or does it not work like that?
global $current_user;
get_currentuserinfo();
return 'http://www.redstow.com/members/' . $current_user->user_login . "/vendordashboard/";
October 13, 2015 at 11:27 am #10756WC Vendors Support
ParticipantUnfortunately, no, that would not work. 🙁
October 13, 2015 at 12:11 pm #10770Laurie
ParticipantHmm ok,
Well for now I’ve used an Iframe to embed it within the buddypress profile. It looks good, but its a messy solution.
October 13, 2015 at 12:46 pm #10772WC Vendors Support
ParticipantThat’s a clever trick. Even if it’s a bit messy, if it works, roll with it! 🙂 If you’d like to share how you did it, I’d be happy to create a KnowledgeBase article for other members to benefit from too.
October 13, 2015 at 2:48 pm #10776Laurie
ParticipantI’m not particularly advanced with php however I put the following code inside my functions.php file
function add_dashboard_tabs() {if (class_exists('WC_Vendors')) {
$wcv_profile_id = bp_displayed_user_id();
$wcv_profile_info = get_userdata( bp_displayed_user_id() );//checking if user is a vendor and is viewing their own profile
if ( $wcv_profile_info->roles[0] == "vendor" && bp_is_my_profile() == true ) {
global $bp;bp_core_new_nav_item( array(
'name' => 'Dashboard',
'slug' => 'Dashboard',
'parent_url' => $bp->displayed_user->domain,
'parent_slug' => $bp->profile->slug,
'screen_function' => 'dashboard_screen',
'position' => 200,
'default_subnav_slug' => 'Dashboard'
) );}
}
}
add_action( 'bp_setup_nav', 'add_dashboard_tabs', 100 );function dashboard_screen() {
add_action( 'bp_template_content', 'dashboard_screen_content' );
bp_core_load_template( apply_filters( 'bp_core_template_plugin', 'members/single/plugins' ) );
}function dashboard_screen_content() {
?>
<div id="my-div">
//alter web adress so it links to the dashboard on your site
<iframe src="http://www.redstow.com/dashboard/" id="my-iframe" scrolling="no"></iframe>
</div>
<?php}
Use the following css but alter to suit your layout in order to get the iframe to show just the dashboard. on the dashboard page I removed all elements except the dashboard, you might want to do the same.
#my-div
{
width : 100%;
height : 1500px;
overflow : hidden;
position : relative;
}#my-iframe
{
position : absolute;
top : 0px;
left : 0px;
width : 1280px;
height : 1200px;
}
October 13, 2015 at 2:57 pm #10779Laurie
Participantsorry for some reason it added html to my code?
October 13, 2015 at 3:56 pm #10783WC Vendors Support
ParticipantWhenever you want to paste code, use pastebin or gist.github.com and just add a link here, it’ll auto add it to your post and format it properly. 🙂
The dashboard is begin rewritten right now, is nearly complete, to remove all foundation css from it so that there are no weird layouts or conflicts. This will be in v1.0.2 due really really soon. 🙂
October 13, 2015 at 3:58 pm #10784Laurie
ParticipantThanks! Will do that in future!
Looking forward to v1.0.2 I have a growing list off css changes!
October 13, 2015 at 4:02 pm #10785WC Vendors Support
ParticipantHopefully you won’t need any of the css changes when 1.0.2 is ready. 😉
October 24, 2015 at 2:48 pm #12211mc24
ParticipantHi ben, Hi Laurie, Like you Laurie I have the kleo theme and I managed in 3 minutes to integrate the WC pro dashboard in buddy press profile menu with the plugin : BuddyPress Custom Profile Menu. Hope this will help. Now, I am trying to integrate the vendors products anyone would know how to do?
ThanksOctober 24, 2015 at 5:18 pm #12220Anna
Member@mc24
This may be helpful to you. I’ve used a customized version of this on my site. https://gist.github.com/digitalchild/5ff5bf34571a4adef995#file-gistfile1-phpOctober 24, 2015 at 5:48 pm #12221mc24
ParticipantThank you anna for your help. Unfortunately it has never worked. I tried many times. What I managed to, is create a page with product with shortcodes
[wcv_recent_products vendor=”VENDOR-LOGIN-NAME” per_page=3][wcv_products vendor=”VENDOR-LOGIN-NAME”]
[wcv_featured_products vendor=”VENDOR-LOGIN-NAME”]
It works as I have a product tab on buddy press but it does show all the store’s products and not just one vendor’s product. I might have a problem…
And even in the page I created, it shows me all the products and not only just one vendor’s.
October 24, 2015 at 6:17 pm #12223Anna
MemberHmmmm. that’s weird that it does not work for you. 🙁
I also use the same theme as you are using, and I have it integrated well with a fontello icon and everything on the member’s BP profile page. It is a new “tab” icon that when selected it will show that vendor’s products.Let me check my code and see if I had to alter anything to get it to work….
October 24, 2015 at 6:23 pm #12224Anna
MemberAhhh it may need to be changed a bit with PRO. I haven’t fully integrated with Pro yet since there are still some stying issues I am having and I am waiting for the next “patch” to see if the issues are fixed.
So….. if it is trying to find the free Wc Vendor shop pages it might not work. I’m not sure yet if any of those lines need to be slightly changed with the Pro enabled.
In addition, I remember not being able to get it to work by placing it in my bp files so I just put it in my child theme functions.php and it works fine.
November 4, 2015 at 2:33 pm #13912Mark
ParticipantMC24, I am trying to do something very similar as you. I have KLEO, PmPro, buddypress, and WC Vendors Pro.
I used BuddyPress Custom Profile Menu plug, added a tab pointing to a page with the shortcode [wcv_products vendor=”VENDOR-LOGIN-NAME”], but just like you it shows all of the products created on my site and not just the products for that particular Buddypress Member profile I am viewing.
Did you find a way to filter out all products from displaying that were not created by the current buddypress member profile we are viewing?
November 4, 2015 at 3:34 pm #13922WC Vendors Support
Participant@mtgame21 — Make sure the vendor-login-name is the user_login of the vendor. As an example, if you were a vendor here, you would be vendor=”mtgame21″
If that doesnt work, create a test page with the shortcode. If it works there, something in Buddypress might be screwing up the shortcode arguments somehow.
Ben
January 6, 2016 at 3:06 pm #20113Laurie
ParticipantHi,
Just revisiting this issue and wondering if there is a way to edit the “Pro Dashboard Page” setting to allow a php variable like below.
$getusername = bp_get_displayed_user_username(); return 'http://www.redstow.com/members/' . $getusername . "/dashboard/";
January 6, 2016 at 4:05 pm #20115WC Vendors Support
ParticipantNope
January 6, 2016 at 7:15 pm #20132Laurie
ParticipantI’ll stick with an Iframe for now, incase anyone is following I’m using the code below. I’ve put the dashboard on a completely blank page with no other elements. I’ve also used JS in order to adjust the iframe according to the size of the dashboard.
// add dashboard tab to buddypress function add_dashboard_tabs() { if (class_exists('WC_Vendors')) { $wcv_profile_id = bp_displayed_user_id(); $wcv_profile_info = get_userdata( bp_displayed_user_id() ); //checking if user is a vendor and is viewing their own profile if ( $wcv_profile_info->roles[0] == "vendor" && bp_is_my_profile() == true ) { global $bp; bp_core_new_nav_item( array( 'name' => 'Dashboard', 'slug' => 'Dashboard', 'parent_url' => $bp->displayed_user->domain, 'parent_slug' => $bp->profile->slug, 'screen_function' => 'dashboard_screen', 'position' => 200, 'default_subnav_slug' => 'Dashboard' ) ); } } } add_action( 'bp_setup_nav', 'add_dashboard_tabs', 100 ); function dashboard_screen() { add_action( 'bp_template_content', 'dashboard_screen_content' ); bp_core_load_template( apply_filters( 'bp_core_template_plugin', 'members/single/plugins' ) ); } function dashboard_screen_content() { ?> <div id="my-div"> <!-- put your url here --> <iframe src="http://www.your-dashboard-url-here.com/dashboard/" width="100%" height="200px" id="iframe1" marginheight="0" frameborder="0" onLoad="autoResize('iframe1');"></iframe> </div> <?php }
JS i’m using
function autoResize(id){ var newheight; var newwidth; if(document.getElementById){ newheight = document.getElementById(id).contentWindow.document .body.scrollHeight; newwidth = document.getElementById(id).contentWindow.document .body.scrollWidth; } document.getElementById(id).height = (newheight) + "px"; document.getElementById(id).width = (newwidth) + "px"; }
February 6, 2016 at 12:11 pm #23193Magnus
ParticipantJust reopening:
Would it be possible, to hook into the code of WC Vendor, and change the button links and so on, so it would fit with a buddy press profile integration?
Just a simple question, I dont know much about php.
February 6, 2016 at 1:32 pm #23201WC Vendors Support
ParticipantIt’s possible to do anything, just a matter of how to code it. If you want to create your own button links, probably easier to just write the button links instead of re-sorting ours.
February 6, 2016 at 1:41 pm #23207Magnus
ParticipantI see – would the shortcode way, then work? If I did the button links aswell?
February 6, 2016 at 1:46 pm #23209WC Vendors Support
ParticipantThe shortcode for the Pro Dashboard will only work on the page that has the shortcode, AND is also configured to be the page in wp-admin > WooCommerce > WC Vendors > Pro > Pro Dashboard Page. It cant be used as a standalone shortcode anywhere you want, that page *must* be set. It all comes down to dynamic URL rewrites.
All of the links on the dashboard pages never change, it just shows you what you configure it to show. e.g., /dashboard/product for products, /dashboard/order for orders, etc… So if you want to build your own menu bar, just design it with the links to the dashboard as you see fit.
Integrating the Pro Dashboard page to show within BuddyPress member pages (aka /members/ben/dashboard/) is not currently possible, and I dont think we have any plans to add features for that in the future.
February 6, 2016 at 1:55 pm #23214Magnus
ParticipantAs mentioned it kindof worked, so far. As you say, everything can be done in matter of coding. 🙂
February 7, 2016 at 4:09 pm #23344Laurie
ParticipantHi, Could you tell me how you’re displaying the products on the products dashboard page? I’m finding it hard to work out.
Thanks!
March 18, 2016 at 5:38 am #27219Konrad Sroka
ParticipantHey guys we just released a FREE WordPress plugin to
add the WC Vendors Dashboard into BuddyPress profiles!
Download directly from your WP admin, just search for “BP WC Vendors”
Visit plugin page at WordPress.org
https://wordpress.org/plugins/bp-wc-vendors/😉 cheers, konrad
-
AuthorPosts
- The forum ‘WC Vendors Pro Support’ is closed to new topics and replies.