AnsPress 2.0 – User Profile -> pull request

6.05K viewsCore
1

Hi,

I figured out how to add a custom tab to the user-profile.
I love the extension-pattern that you applied! Thanks!

One issue I found was that the tab-page which I registered with
ap_register_user_page('testtab', __('Test tab', 'ap'), array('AnsPress_User_Page_Test', 'output'));
came first in the menu list. Probably because I called the ap_register_user_page too early.

Anyway, it started me thinking that things might get nasty when multiple plugins want to add a tab -> in which order will they be added?
So I have made some changes to the anspress-master\includes\user.php file in such way that you can now specify an order when registering a tab:
ap_register_user_page('testtab', __('Test tab', 'ap'), 90, array('AnsPress_User_Page_Test', 'output'));

If you agree to it, you can find the changes here: https://www.dropbox.com/s/l2mu2mtfv1kiwwa/user.php?dl=0
I have all the changed sections marked with the //MVRM comment, so you can easily find my changes.

Greetings,

Michiel

0

Here is an example for sorting a menu item

add_filter('ap_user_menu', 'my_user_menu_override');
function my_user_menu_override($menu){
	if(Isset($menu['questions']))
		$menu['questions']['order'] = 1; // add order key here, default order key is 10

	return $menu;
}

This is working fine 🙂 Thanks

You are viewing 1 out of 3 answers, click here to view all answers.