AnsPress 2.0 – User Profile -> pull request

5.30K 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

0

Hi, I think I succeeded in creating a pull request:
https://github.com/wp3/anspress/pull/243
I don’t know if it was still needed for this change but I just wanted to sort out how to do this so I’m future-proof 😉

Working on it 😉

1

Michiel, Yeh its a good idea. But do not post your code in box.com instead fork our Github anspress and then send pull request.

Hi Rahul what about login could you fix ?

will check your issues today.

Ok, I will look in how to do that. Never created a pull request before 🙂

Rahul, should I create a GitHub pull request for this change too? Or will you use the file in dropbox for this one time?

Hi Rahul, I saw your commit on GitHub titled “Added sorting in user menu”, but after downloading the latest version my menu isn’t sorted anymore. Should I set the sorting in another way (not as 3th param of ap_register_user_page)? Thanks