Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
<?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');
@cartpauj

This comment has been minimized.

Copy link
Owner Author

cartpauj commented Jul 27, 2017

Line #24 and down can be deleted if you're just redirecting the user to an existing page somewhere else on the site.

@littlered23

This comment has been minimized.

Copy link

littlered23 commented Sep 17, 2018

This is great, thanks! A bit of a noob here, but is it possible to render a specific custom field on a new nav? I have been messing around with MeprUsersHelper::render_custom_fields(null, 'account'); MeprHooks::do_action('mepr-account-home-fields', $mepr_current_user); but I can't get it to display a specific checkboxes field.

@modsnap

This comment has been minimized.

Copy link

modsnap commented Jan 27, 2019

I'm using MemberPress in conjunction with Toolset to be able to have a visible Business Directory for our members. I would like the Account page to have a tab for a member to be able to edit their business directory listing - in much the same way that they can edit their member user account info. I have used the code above to create the tab, however, I need code to incorporate the Toolset CRED form shortcode into the functions.php file. Is it possible and if so, can you help?

@cartpauj

This comment has been minimized.

Copy link
Owner Author

cartpauj commented Jun 26, 2019

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.