Home Forums Plugin Support WP User Frontend Pro Multiple dashboard

This topic is: resolved

This topic contains 15 replies, has 2 voices, and was last updated by  Tareq Hasan 6 years ago.

Viewing 15 posts - 1 through 15 (of 16 total)
  • Author
    Posts
  • #4385

    noomia
    Participant
    Post count: 115

    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 ๐Ÿ™‚ !

    #4457

    noomia
    Participant
    Post count: 115

    Hi Tarek !

    Have you got any news ๐Ÿ™‚ ?

    #4476

    Tareq Hasan
    Keymaster
    Post count: 2831

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

    PS: Spelling of name would be “TareQ

    #4535

    noomia
    Participant
    Post count: 115

    Hi and sorry TareQ ๐Ÿ˜‰

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

    #4537

    Tareq Hasan
    Keymaster
    Post count: 2831

    No it's not currently. But you can add filters based on post type ๐Ÿ™‚

    #4540

    noomia
    Participant
    Post count: 115

    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 ?

    #4556

    Tareq Hasan
    Keymaster
    Post count: 2831

    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.

    #4568

    noomia
    Participant
    Post count: 115

    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 ๐Ÿ˜‰ !

    #4569

    Tareq Hasan
    Keymaster
    Post count: 2831

    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]

    #4570

    noomia
    Participant
    Post count: 115

    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…

    #4571

    noomia
    Participant
    Post count: 115

    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…

    #4574

    Tareq Hasan
    Keymaster
    Post count: 2831

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

    #4575

    noomia
    Participant
    Post count: 115

    Nice, well done, it's working ๐Ÿ™‚ !

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

    #4578

    Tareq Hasan
    Keymaster
    Post count: 2831

    Dashboard title, NO.
    Adding columns, Yes.

    #4583

    noomia
    Participant
    Post count: 115

    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

Viewing 15 posts - 1 through 15 (of 16 total)

The topic ‘Multiple dashboard’ is closed to new replies.