{"id":1719351,"date":"2020-09-15T12:47:50","date_gmt":"2020-09-15T12:47:50","guid":{"rendered":"https:\/\/toolset.com\/?post_type=course-lesson&#038;p=1719351"},"modified":"2021-01-26T15:58:33","modified_gmt":"2021-01-26T15:58:33","slug":"adding-toolset-blocks-to-the-woocommerce-my-account-page","status":"publish","type":"course-lesson","link":"https:\/\/toolset.com\/fr\/course-lesson\/adding-toolset-blocks-to-the-woocommerce-my-account-page\/","title":{"rendered":"Adding Toolset Blocks to the WooCommerce My Account Page"},"content":{"rendered":"\n<p>Let&#8217;s go over the most popular use-cases for customizing the WooCommerce &#8220;My Account&#8221; page with Toolset.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Hide Additional Content from Visitors<\/h2>\n\n\n\n<p>Before actually adding anything to the &#8220;My Account&#8221; page, let&#8217;s make sure we display additional content only to logged-in Customers. Remember, visitors that are not logged-in could also reach this page. In this case, the custom content you add to this page wouldn&#8217;t make sense and most of it would render empty. <\/p>\n\n\n\n<p>Steps to display custom content on the &#8220;My Account&#8221; page only for Customer and Administrator roles:<\/p>\n\n\n\n<ol class=\"wp-block-list\"><li>Insert the Toolset <strong>Conditional<\/strong> block. Click the button to add conditions and a pop-up dialog appears.<\/li><li>In the left dropdown, select the <strong>Current user role<\/strong> option.<\/li><li>In the right dropdown, select the <strong>Other role<\/strong> option.<\/li><li>In the new dropdown that appears, select <strong>Customer<\/strong>.<\/li><\/ol>\n\n\n<div class=\"wp-block-image\">\n<figure class=\" tb-image tb-image-media aligncenter\" data-toolset-blocks-image=\"ec50cd2ac895a60eee94929c737efe06\"><a href=\"https:\/\/toolset.com\/wp-content\/uploads\/2020\/09\/toolset-woocommerce-display-content-only-to-customer-users.png\"><img decoding=\"async\" loading=\"lazy\" src=\"https:\/\/toolset.com\/wp-content\/uploads\/2020\/09\/toolset-woocommerce-display-content-only-to-customer-users-500x130.png\" alt=\"\" class=\"wp-image-1773271\"\/><\/a><div class=\"tb-image-caption\"><figcaption>Using the Toolset Conditional block to display content only to users with a Customer role<\/figcaption><\/div><\/figure>\n<\/div>\n\n\n<p>You will probably want the site&#8217;s administrator to also see this content on the front-end.<\/p>\n\n\n\n<ol class=\"wp-block-list\"><li>Still in the same dialog, click the <strong>plus <\/strong>button to add another condition.<\/li><li>This time, select <strong>Other role<\/strong> \u2192 <strong>Administrator<\/strong>.<\/li><\/ol>\n\n\n\n<p>That&#8217;s it, click <strong>Accept<\/strong> and then put all your additional custom content inside the <strong>Conditional <\/strong>block.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Add a List of Posts Submitted by the Current User<\/h2>\n\n\n\n<div class=\"tb-fields-and-text\" data-toolset-blocks-fields-and-text=\"360284519b991feb492b582c7d84725f\">With Toolset, you can create forms so users can <a href=\"https:\/\/toolset.com\/fr\/course-lesson\/front-end-forms-for-adding-content\/\">submit new content from the front-end<\/a>.<\/div>\n\n\n\n<p>&#8220;My Account&#8221; page is a sensible place to show the current user a list of posts that they have submitted.<\/p>\n\n\n\n<p>Use the following steps to create such View:<\/p>\n\n\n\n<ol class=\"wp-block-list\"><li>Edit the &#8220;My Account&#8221; page.<\/li><li>Insert the&nbsp;<strong>View&nbsp;<\/strong>block either before or after the block containing the <strong>woocommerce_my_account<\/strong>&nbsp;shortcode. <\/li><li>Create a new View, select the type of content you want to list, and design its output using blocks.<\/li><li>Click to select the main&nbsp;<strong>View&nbsp;<\/strong>block and in the right sidebar, expand the&nbsp;<strong>Content Selection<\/strong>&nbsp;section.<\/li><li>In the <strong>Query Filters<\/strong> sub-section, click <strong>Add a filter<\/strong>.<\/li><li>In the dialog that appears, select to filter by&nbsp;<strong>Post author<\/strong>&nbsp;and click&nbsp;<strong>Add query filter<\/strong>.<\/li><li>In the right sidebar, select the&nbsp;<strong>Post author is the same as the logged in user&nbsp;<\/strong>option and click&nbsp;<strong>Save<\/strong>.<\/li><\/ol>\n\n\n\n<p>Users will now see a list of the posts they submitted.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\" tb-image tb-image-media aligncenter\" data-toolset-blocks-image=\"b61092d7afb6f50ef66dbc102e74f60d\"><img decoding=\"async\" loading=\"lazy\" src=\"https:\/\/toolset.com\/wp-content\/uploads\/2020\/09\/toolset-customized-woocommerce-my-account-page-500x350.png\" alt=\"\" class=\"wp-image-1773511\"\/><div class=\"tb-image-caption\"><figcaption>WooCommerce &#8220;My Account&#8221; page with a list of posts submitted by the current user<\/figcaption><\/div><\/figure>\n<\/div>\n\n\n<div class=\"tb-fields-and-text\" data-toolset-blocks-fields-and-text=\"360284519b991feb492b582c7d84725f\">You might want to also allow them to edit or delete their posts. You can learn more about this in the lesson about <a href=\"https:\/\/toolset.com\/fr\/course-lesson\/allow-users-to-manage-their-items\/\">allowing users to manage their items<\/a>.<\/div>\n\n\n\n<h2 class=\"wp-block-heading\">Add Extra User Fields to the My Account Page<\/h2>\n\n\n\n<p>WordPress provides some basic fields for user profiles like name, nickname, email, website, and more.<\/p>\n\n\n\n<p>With Toolset, you can add any custom fields to your user profiles:<\/p>\n\n\n\n<ol class=\"wp-block-list\"><li>Go to <strong>Toolset <\/strong>\u2192 <strong>Custom Fields<\/strong>, click the <strong>User Fields <\/strong>tab, and then the <strong>Add New Group<\/strong> button.<\/li><li>Give a name to your new group of custom user fields.<\/li><li>Click the <strong>Add New Field <\/strong>button to add a field. You can add any number of fields.<\/li><\/ol>\n\n\n\n<p>Now, all user profiles will include the fields you added.<\/p>\n\n\n\n<p>Of course, you can then also display them on the front-end:<\/p>\n\n\n\n<ol class=\"wp-block-list\"><li>Edit the &#8220;My Account&#8221; page.<\/li><li>Insert&nbsp;the <strong>Fields and Text <\/strong>block either before or after the block containing the <strong>woocommerce_my_account<\/strong>&nbsp;shortcode. You can use any number of <strong>Fields and Text<\/strong> blocks.<\/li><li>In the editor of the <strong>Fields and Text <\/strong>block, click the <strong>Views <\/strong>button.<\/li><li>In the pop-up dialog that appears, you can find your custom group of user fields. Click the user field you want to insert. <\/li><li>Select the option to display the field for the current logged in user and click <strong>Insert shortcode<\/strong>.<\/li><\/ol>\n\n\n<div class=\"wp-block-image\">\n<figure class=\" tb-image tb-image-media aligncenter\" data-toolset-blocks-image=\"1e8ecf1980a2eeede605a27c048ec468\"><a href=\"https:\/\/toolset.com\/wp-content\/uploads\/2020\/09\/toolset-display-custom-user-fields-on-woocommerce-my-account-page.png\"><img decoding=\"async\" loading=\"lazy\" src=\"https:\/\/toolset.com\/wp-content\/uploads\/2020\/09\/toolset-display-custom-user-fields-on-woocommerce-my-account-page-500x314.png\" alt=\"\" class=\"wp-image-1773279\"\/><\/a><div class=\"tb-image-caption\"><figcaption>Custom user fields displayed on the WooCommerce &#8220;My Account&#8221; page<\/figcaption><\/div><\/figure>\n<\/div>\n\n\n<h2 class=\"wp-block-heading\">Further Customization of the Custom Content<\/h2>\n\n\n\n<p>Besides adding custom content to the &#8220;My Account&#8221; page, you can use any 3rd-party blocks for designing.<\/p>\n\n\n\n<p>For example, if you want to display all your extra custom information inside tabs, we suggest using <a href=\"https:\/\/wordpress.org\/plugins\/kadence-blocks\/\">Kadence Blocks<\/a>. Their Tabs block provides horizontal and vertical tabs with great designing options.<\/p>\n","protected":false},"author":17621,"featured_media":1773519,"template":"","related-lesson":[8445],"class_list":["post-1719351","course-lesson","type-course-lesson","status-publish","has-post-thumbnail","hentry","related-lesson-e-commerce"],"_links":{"self":[{"href":"https:\/\/toolset.com\/fr\/wp-json\/wp\/v2\/course-lesson\/1719351","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/toolset.com\/fr\/wp-json\/wp\/v2\/course-lesson"}],"about":[{"href":"https:\/\/toolset.com\/fr\/wp-json\/wp\/v2\/types\/course-lesson"}],"author":[{"embeddable":true,"href":"https:\/\/toolset.com\/fr\/wp-json\/wp\/v2\/users\/17621"}],"version-history":[{"count":8,"href":"https:\/\/toolset.com\/fr\/wp-json\/wp\/v2\/course-lesson\/1719351\/revisions"}],"predecessor-version":[{"id":1776229,"href":"https:\/\/toolset.com\/fr\/wp-json\/wp\/v2\/course-lesson\/1719351\/revisions\/1776229"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/toolset.com\/fr\/wp-json\/wp\/v2\/media\/1773519"}],"wp:attachment":[{"href":"https:\/\/toolset.com\/fr\/wp-json\/wp\/v2\/media?parent=1719351"}],"wp:term":[{"taxonomy":"related-lesson","embeddable":true,"href":"https:\/\/toolset.com\/fr\/wp-json\/wp\/v2\/related-lesson?post=1719351"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}