Skip Navigation

[Resolved] trying to filter posts by profile page author

This support ticket is created 2 years, 7 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.

Sun Mon Tue Wed Thu Fri Sat
- 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Kolkata (GMT+05:30)

This topic contains 12 replies, has 2 voices.

Last updated by Directory 2 years, 7 months ago.

Assisted by: Minesh.

Author
Posts
#2173837

I am trying to create a view, but do not understand how to set up the filter to show only posts by the author whose profile page is being viewed.

The issue seems to have been resolved in a previous ticket (https://toolset.com/forums/topic/view-widget-to-display-all-posts-by-a-user-on-their-profile/) but i seems to stop working around step 3/4

#2173923

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hello. Thank you for contacting the Toolset support.

Can you please share problem URL and one admin login access details and one author account access details so that I can login to author account and run a test to see if view displays the correct posts.

Please share what view you created.

*** Please make a FULL BACKUP of your database and website.***
I would also eventually need to request temporary access (WP-Admin and FTP) to your site. Preferably to a test site where the problem has been replicated if possible in order to be of better help and check if some configurations might need to be changed.

I have set the next reply to private which means only you and I have access to it.

#2176103

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

I see both post's author is admin: hidden link

Is it possible for you to set correct author, for "First Tester Top 10 Admin" the author should be minesh and for the other post "Second tester book by admin" the author should be "tester".

#2176199

Ok i have done as requested

#2176211

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

No - I mean to say that when you create those posts in future will it be possible for you to set post author for such new posts created in future?

Will you have only one profile post per user? if yes: then I hope you will be able to manage and assign the correct user as post author.

#2176433

yes when a user sumbits a post it will automatically asign them as the author

#2176439

Yes when a user submits a post it will automatically assign them as the author . . . there will be no need to do it manually

#2178511

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

The thing is that the profile seems to be rendered as buddypress member profile.

There were two issue.
1) Display dynamic current member profile name

To display the dynamic current profile user name. I've created the following shortcode and added it to "Custom Code" section offered by Toolset:
=> hidden link

add_shortcode( 'get_member_profile_name', 'func_get_member_profile_name' );
function func_get_member_profile_name() {
  global $bp;
 
  return $bp->displayed_user->userdata->user_login;
}

It returns the username.

And within your elemenor's template, I've added the shortcode as given under.

[get_member_profile_name]'s

2) Filter the view with the current member profile author

In addition to that, we can not use view's shortcode attribute to pass the current profile member ID as shortcode within the elemenor as it does not parse the nested shortcode correctly:

[wpv-view name="user-top-10-books" userusername='[get_member_profile_id]']

As above solution was not possible, as a workaround:

To filter the view with the current profile author ID, I've added the following view's filter to "Custom Code" section offered by Toolset:

add_filter( 'wpv_filter_query', 'func_filter_view_by_author',10,3);
function func_filter_view_by_author( $query_args, $view_settings, $view_id ) {
  global $bp;
    
 
  if($view_id == 2223){  
     $query_args['author__in'] = array($bp->displayed_user->id);
    }
    return $query_args;
 
  }

Now, the thing is that with the view, you build your loop output using block:
=> hidden link

As you are using the view within the elementor, we do not recommend to use views or view's loop output build in block as it will cause the compatibility issue. So you have to build the view's loop without using the block.
=> hidden link

I can see now, that on tester member profile page, it shows the correct post:
=> hidden link

As well as on minesh member profile: hidden link

#2179073

Thanks Minesh,

The changes you have made see to have been effective and your explanation helped me to begin to get my head around it.

one thing i was quite clear on though . . . we do not recommend to use views or view's loop output build in block . . . . so does this mean that i should click the link/button that says "Stop using Block Editor for this Content Template" and proceed with coding to avoid compatibility issues with Elementor ?

#2180605

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

one thing i was quite clear on though . . . we do not recommend to use views or view's loop output build in block . . . . so does this mean that i should click the link/button that says "Stop using Block Editor for this Content Template" and proceed with coding to avoid compatibility issues with Elementor ?
==>
Yes, thats correct. You will have to build the view's loop output using legacy view instead of blocks mode.

#2180815

Thanks Minesh,

You have been very helpful.

Finally are you able to suggest any Toolset Videos/tutorials around using building view loop using legacy views.

Many Thanks Again.

#2180833

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Here is the Doc link for legacy views. You can check which link you will require.
=> https://toolset.com/documentation/legacy-features/views-plugin/

#2180903

My issue is resolved now. Thank you!

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.