Multiple dashboard

This topic contains 15 reply and 2 voices, and was last updated by Tareq Hasan 11 years, 5 months ago
Viewing 15 Posts - 1 through 15 (of 15 total)
Author Posts
May 31, 2013 at 2:38 pm 4385
Tareq Hasan Hi Tarek ! In my project, as you know, users can create multiple companies and multiple post types for each company(each post has a "company_id" custom field related to the right company's id). Right now, I have a page which lists the user's companies. Newt to the company's name, I have a link to a dashboard page which lists the posts related to that company (thanks to $args['meta_query'] in wpuf_dashboard_query). This configuration is not optimal for the UX. We have discussed it a lot and here is what we would like : New structure So as you can see, we want everything in a single page : the list of the companies, and multiple "dashboard", each related to his company. Is it possible to do that as it's now or do I have to make it myself, and recreate the dashboard table with wp_query/get_posts... ? I also want to add a post_type column in the table. Thank you for your great support :) !
June 3, 2013 at 7:40 am 4457
noomia noomia

Hi Tarek !

Have you got any news 🙂 ?

June 3, 2013 at 4:53 pm 4476
Tareq Hasan Tareq Hasan

Is there any problem using multiple dashboard shortcode on that page?

PS: Spelling of name would be “TareQ

June 4, 2013 at 2:25 pm 4535
noomia noomia

Hi and sorry TareQ 😉

Is it possible to add dashboard query in the dashboard shortcode ?

June 4, 2013 at 3:13 pm 4537
Tareq Hasan Tareq Hasan

No it’s not currently. But you can add filters based on post type 🙂

June 4, 2013 at 3:23 pm 4540
noomia noomia

I don’t understand how I could achieve that… I need multiple dashboard… Each dashboard has to display the news/projects/jobs/events that has a specific value for the custom field “company_id”. I achieve that for the dashboard page thanks to your dashboard query filter. But how achieve that for multiple dashboard on same page ? With the shortcodes ?

June 4, 2013 at 10:49 pm 4556
Tareq Hasan Tareq Hasan

With the dashboard filter, you get the arguments as a parameter, right? And you give different post types in the shortcode. Ex: [wpuf_dashboard post_type="something"], [wpuf_dashboard post_type="another"] So you could check the parameters, by checking the post type you could add different query parameters in different dashboard shortcode. Hope I am clear.

June 5, 2013 at 7:46 am 4568
noomia noomia

In fact, right now, I have one page for each company, so I can pass the ID of the company through the url and retrieve this id. So I have that code :

<?php function wpufe_dashboard_post_type( ) {
	global $current_user; 
	$args['post_type'] = array('news','jobs','events','projects');
	
	if($_GET['company_id']) {
		$post = get_post($_GET['company_id']);
		if ( $current_user->ID == $post->post_author ){
			$args['post_status'] = 'any';
			$args['meta_query'] =  array(array('key' => 'company_id', 'value'=>$post->ID));
			return $args;
		}
	}
}
add_filter( 'wpuf_dashboard_query', 'wpufe_dashboard_post_type' ); ?>

But in the new case, I have all the companies on the same page, so I can’t pass the company ID through the url because it’s not a single ID, maybe 50, and it’s bad in the url. I have a loop to display each company in the loop. In that loop, I have to call the dashboard and pass the company_ID, in the loop, as an argument but I don’t understand how… In the wpuf_dashboard_query , is it possible to have the post_id ?

Thank you for your answers, I’m a little bit in a hurry for this functionnality 😉 !

June 5, 2013 at 7:57 am 4569
Tareq Hasan Tareq Hasan

I was talking about something like this:

[php]
function wpufe_dashboard_post_type( $args ) {
global $current_user;

if( $args[‘post_type’] == ‘company’) {
// do something
} elseif ( $args[‘post_type’] == ‘another’) {
// do something
}

return $args;
}

add_filter( ‘wpuf_dashboard_query’, ‘wpufe_dashboard_post_type’ );
[/php]

June 5, 2013 at 8:11 am 4570
noomia noomia

I’m afraid you don’t understand everything 😉 !

I have the “companies” post type.
I also have 4 custom post type : “news”, “jobs”, “projects”, “events”. These post types have a custom field that contains a company_ID.

In the loop, I display all the companies. It’s a classic loop to get the custom post type “companies”. In that loop, for each company, I need the WPUF dashboard. This dashboard has to display the 4 others custom post type : “news”, “jobs”, “projects”, “events”. Not the “companies” post type. But each dashboard has to displays the 4 posts types that has a the good company_ID. So if in the loop we are displaying the company with ID=64, the dashboard has to display the post types “news”, “jobs”, “projects”, “events” where the custom field company_ID=64.

Do you understand ?

So I only need a way to retrieve the ID of the post where the dashboard shortcode is called…

June 5, 2013 at 8:49 am 4571
noomia noomia

Like with the Hook, we can retrieve the post_id (and the form_id)

function my_hook( $form_id, $post_id, $form_settings ) { ... }

Could be great to retrieve the post ID for dashboard…

June 5, 2013 at 9:24 am 4574
Tareq Hasan Tareq Hasan

If it’s a WordPress loop, you can access global $post variable in the filter. So may be you can take advantage of that?

June 5, 2013 at 9:37 am 4575
noomia noomia

Nice, well done, it’s working 🙂 !

Is there a way to change the Dashboard Title ? And to add a column in the dashboard table ?

June 5, 2013 at 10:03 am 4578
Tareq Hasan Tareq Hasan

Dashboard title, NO.
Adding columns, Yes.

June 5, 2013 at 12:06 pm 4583
noomia noomia

Last question. Is it possible to get the number of posts that are displayed in the dashboard ? You display it in a full sentence, I only need the number…

Thanks

June 7, 2013 at 6:40 pm 4665
Tareq Hasan Tareq Hasan

You can’t change it in the dashboard, there isn’t any filter for that.

Viewing 15 Posts - 1 through 15 (of 15 total)