Receiving error: invalid arguement….

4.96K viewsCore
0

I’m attempting to override the user menu order as requested here http://open-wp.com/questions/question/1548/how-can-i-reorder-the-output-of-the-user-profile-menu/

Taking from anspress-user.php I’m using the following function in my functions.php

function custom_ap_user_menu(){
		$userid = ap_get_user_page_user();
	$user_page = get_query_var('user_page');
	$user_page = $user_page ? $user_page : 'profile';
	
	$menus = array(
		'profile' => array( 'name' => __('Profile', 'ap'), 'link' => ap_user_link($userid), 'icon' => 'ap-icon-user'),
		'favorites' => array( 'name' => __('Favorites', 'ap'), 'link' => ap_user_link($userid, 'favorites'), 'icon' => 'ap-icon-star'),
		'questions' => array( 'name' => __('Questions', 'ap'), 'link' => ap_user_link($userid, 'questions'), 'icon' => 'ap-icon-question'),
		'answers' => array( 'name' => __('Answers', 'ap'), 'link' => ap_user_link($userid, 'answers'), 'icon' => 'ap-icon-answer'),		
		'badges' => array( 'name' => __('Badges', 'ap'), 'link' => ap_user_link($userid, 'badges'), 'icon' => 'ap-icon-badge'),		
		'followers' => array( 'name' => __('Followers', 'ap'), 'link' => ap_user_link($userid, 'followers'), 'icon' => 'ap-icon-users'),
		'following' => array( 'name' => __('Following', 'ap'), 'link' => ap_user_link($userid, 'following'), 'icon' => 'ap-icon-users'),
		'edit_profile' => array( 'name' => __('Edit Profile', 'ap'), 'link' => ap_user_link($userid, 'edit_profile'), 'icon' => 'ap-icon-pencil', 'own' => true),
		//'settings' => array( 'name' => __('Settings', 'ap'), 'link' => ap_user_link($userid, 'settings'), 'icon' => 'ap-icon-cog'),		
	);
	
		/* filter for overriding menu */
	$menus = apply_filters('custom_ap_user_menu', $menus);
	
	$o ='';
	foreach($menus as $k => $m){
		if(!((isset($m['own']) && $m['own']) && $userid != get_current_user_id()))
			$o .= '<a href="'. $m['link'] .'">'.$m['name'].'</a>';
	}
	$o .= '';
	
	echo $o;

}
add_filter ( 'ap_user_menu' , 'custom_ap_user_menu' , 10, 2 );

My custom menu order displays correctly, but it is now throwing an error from within the plugin:

Warning: Invalid argument supplied for foreach() in /home/teatrade/public_html/dev.prometheusfire.me/interview-hacks/wp-content/plugins/anspress-question-answer/includes/anspress-user.php on line 509

Can you help me please sort this out. Everything looks right in the code as far as I can tell so I can’t see why I’m getting the error. Ultimately, I don’t care how its done, what I really want is to move the Favorites link next to the Profile link.

0

And also make sure to undo your last changes before adding my codes.

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