<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Forem: Harner Designs</title>
    <description>The latest articles on Forem by Harner Designs (@harnerdesigns).</description>
    <link>https://forem.com/harnerdesigns</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Forganization%2Fprofile_image%2F412%2F6b485561-9444-4e02-b923-d8fa828af58c.png</url>
      <title>Forem: Harner Designs</title>
      <link>https://forem.com/harnerdesigns</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/harnerdesigns"/>
    <language>en</language>
    <item>
      <title>Add Logout Link To Account Menu - BigCommerce For WordPress</title>
      <dc:creator>Jack Harner 🚀</dc:creator>
      <pubDate>Mon, 22 Apr 2019 20:59:01 +0000</pubDate>
      <link>https://forem.com/harnerdesigns/add-logout-link-to-account-menu-bigcommerce-for-wordpress-1jne</link>
      <guid>https://forem.com/harnerdesigns/add-logout-link-to-account-menu-bigcommerce-for-wordpress-1jne</guid>
      <description>&lt;p&gt;&lt;em&gt;&lt;a href="https://harnerdesigns.com/blog/add-logout-link-to-account-menu-bigcommerce-for-wordpress/"&gt;Originally posted on Harner Designs' Blog&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;BigCommerce for WordPress (BC4WP) allows you to combine the power of the BigCommerce back-end with the customization of WordPress on the front-end for a truly unique E-Commerce experience. &lt;/p&gt;

&lt;p&gt;One thing that seems missing out of their integration is a logout link on the My Account page:&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--NrX_rxYF--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://harnerdesigns.com/wp-content/uploads/2019/04/Before-Code.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--NrX_rxYF--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://harnerdesigns.com/wp-content/uploads/2019/04/Before-Code.png" alt="BC4WP Account Menu - Before"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;It seemed like an easy fix and since I've started to dabble in making pull requests to Open Source Software, I decided to take a look. The "SubNav" as they've called it is populated in &lt;code&gt;bigcommerce-for-wordpress/src/BigCommerce/Accounts/Sub_Nav.php&lt;/code&gt;. It uses &lt;code&gt;get_option&lt;/code&gt; to pull the stored Account, Orders, &amp;amp; Address pages and populates the &lt;code&gt;$links[]&lt;/code&gt; array with the associated data.&lt;/p&gt;

&lt;p&gt;Easy. &lt;/p&gt;

&lt;p&gt;Just append the logout information to the &lt;code&gt;$links[]&lt;/code&gt; array with &lt;code&gt;wp_logout_url()&lt;/code&gt; and the logout link will appear in the my accounts page. &lt;/p&gt;

&lt;p&gt;And thus, my first &lt;a href="https://github.com/bigcommerce/bigcommerce-for-wordpress/pull/150"&gt;Pull Request&lt;/a&gt; to the BC4WP repo was born.&lt;/p&gt;
&lt;h2&gt;
  
  
  Shot Down Like A High Schooler Before Prom
&lt;/h2&gt;

&lt;p&gt;My PR was rejected citing that logging out of WordPress was "Out of Scope" of the BigCommerce for WordPress plugin. However, Jonathan of &lt;a href="https://tri.be/"&gt;Modern Tribe&lt;/a&gt; (the plugin developers) pointed out that there is a filter already applied to the links generated so that Site Admins can add anything they wish to that list of links: &lt;code&gt;bigcommerce/account/subnav/links&lt;/code&gt;. &lt;/p&gt;
&lt;h2&gt;
  
  
  So..? How Do You Do It?
&lt;/h2&gt;

&lt;p&gt;If you're like me and &lt;em&gt;want&lt;/em&gt; to add the logout link to the BigCommerce for WordPress Account Page Submenu, just add the following code to your theme's &lt;code&gt;functions.php&lt;/code&gt; file:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="nf"&gt;add_filter&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'bigcommerce/account/subnav/links'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;function&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$links&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
 &lt;span class="nv"&gt;$links&lt;/span&gt;&lt;span class="p"&gt;[]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
  &lt;span class="s1"&gt;'url'&lt;/span&gt;     &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nf"&gt;wp_logout_url&lt;/span&gt;&lt;span class="p"&gt;(),&lt;/span&gt;
  &lt;span class="s1"&gt;'label'&lt;/span&gt;   &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nf"&gt;__&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'Logout'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'bigcommerce'&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
  &lt;span class="s1"&gt;'current'&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
 &lt;span class="p"&gt;];&lt;/span&gt;
 &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nv"&gt;$links&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;},&lt;/span&gt; &lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And that's it! Now there will be a convenient to use Logout Link on the "My Account" page with BigCommerce for WordPress.&lt;/p&gt;

&lt;h2&gt;
  
  
  Recent Blog Posts
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://harnerdesigns.com/blog/measure-angles-in-illustrator/"&gt;How To Measure Angles In Illustrator&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://harnerdesigns.com/blog/optimizing-my-stars-php-generated-svg-vs-canvas/"&gt;Optimizing My Stars – PHP Generated SVG vs Canvas&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://harnerdesigns.com/blog/unlimited-private-github-repos-for-free-accounts/"&gt;Unlimited Private GitHub Repos for Free Accounts&lt;/a&gt; &lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>wordpress</category>
      <category>bigcommerce</category>
      <category>tutorial</category>
      <category>php</category>
    </item>
  </channel>
</rss>
