Skip to content

Instantly share code, notes, and snippets.

@cartpauj
Last active January 23, 2024 22:39
Show Gist options
  • Save cartpauj/26c89ee92965817eaa10 to your computer and use it in GitHub Desktop.
Save cartpauj/26c89ee92965817eaa10 to your computer and use it in GitHub Desktop.
<?php
/*
Plugin Name: MemberPress Account Page Nav
Plugin URI: http://www.memberpress.com/
Description: Allows developers to add more nav menu links/pages to their members account page
Version: 1.0.0
Author: Caseproof, LLC
Author URI: http://caseproof.com/
Copyright: 2004-2013, Caseproof, LLC
*/
//COPY FROM THE LINE BELOW TO THE END, IF YOU PLAN TO PASTE THIS CODE INTO A THEME'S functions.php FILE OR INTO A PLUGIN LIKE My Custom Functions
//ADD A SUPPORT TAB TO THE NAV MENU
function mepr_add_some_tabs($user) {
$support_active = (isset($_GET['action']) && $_GET['action'] == 'premium-support')?'mepr-active-nav-tab':'';
?>
<span class="mepr-nav-item premium-support <?php echo $support_active; ?>">
<a href="/account/?action=premium-support">Premium Support</a>
</span>
<?php
}
add_action('mepr_account_nav', 'mepr_add_some_tabs');
//YOU CAN DELETE EVERYTHING BELOW THIS LINE -- IF YOU PLAN TO REDIRECT
//THE USER TO A DIFFERENT PAGE INSTEAD OF KEEPING THEM ON THE SAME PAGE
//ADD THE CONTENT FOR THE NEW SUPPORT TAB ABOVE
function mepr_add_tabs_content($action) {
if($action == 'premium-support'): //Update this 'premium-support' to match what you put above (?action=premium-support)
?>
<div id="custom-support-form">
<form action="" method="post">
<label for="subject">Enter Subject:</label><br/>
<input type="text" name="subject" id="subject" />
<br/><br/>
<label for="content">Enter Content:</label><br/>
<input type="text" name="content" id="content" />
<br/><br/>
<input type="submit" name="premium-support-submit" value="Submit" />
</form>
</div>
<?php
endif;
}
add_action('mepr_account_nav_content', 'mepr_add_tabs_content');
@ravasheen
Copy link

FYI - there's now a 3rd party plugin that does this without any coding necessary: https://meprtoolbox.com/product/account-navigation-tabs/

This company seems to be no longer active but they are supporting previous purchases :( But your code is a godsend! thank you!

@AnitaLobban
Copy link

How or where do I insert the php code into my accounts page via the plug in? Thanks
I'm new to all this php stuff

@Tri-Ryuzaki
Copy link

@AnitaLobban You will need to install and active code snippet plugin (https://wordpress.org/plugins/code-snippets/). ---> Create a new snippet and copy-paste those codes above to your snippet ---> Check on "Only run on site front-end" then hit Save . Done =)

@umm-wdc
Copy link

umm-wdc commented Feb 17, 2022

@cartpauj , is there a way to hide an existing tab eg: i want to hide the Home tab and set default tab to Subscriptions. Is that possible ?

@nfsarmento
Copy link

Hi @Tri-Ryuzaki & @cartpauj do you know how to order custom memberpress account nav items ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment