It seems I can build a view that might get me what I want but wanted to make sure I am proceeding properly with your plugin. We have users marked as contributors (about 300) and we have 200 of them with published directory listings. Can you help me with the best way to pull a list of the 100 that have not submitted a listing? To be clear, they have submitted a form to create an account but have not yet added content. We want to identify them.
Additionally, along the same lines, we have these users that have created an account but would like an automated way to switch their role once they have submitted a form to post content. Is this possible with your software?
Hello. Thank you for contacting the Toolset support.
To display the users list who do not have added any posts, we will have to find first all users who have publish the posts and then we can use not in clause to get all users who do not have added any post.
If you can share admin access details and tell me for what post type you want to check that user do not added any post to it.
*** Please make a FULL BACKUP of your database and website.***
I would also eventually need to request temporary access (WP-Admin) 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.
As per our support policy, we entertain only one question per ticket. This will help other users searching on the forum as well as help us to write correct problem resolution summery for the original issue reported.
I suggest you to open a new ticket with every new question you may have.
For the original issue regarding the displaying the list of users who do not have directly published post.
I've created the following view that query the User role "Contributor:
=> hidden link
[ you can adjust the "loop output" section and display what ever fields you want to display it]
With "Custom Code" section I've added the following code:
=> hidden link
I've created the following test page and saved it as a "Draft" where I've added the User view I've created above using the "Fields and Text" block:
=> hidden link
Now, if you can check on the frontend, it lists all users who do not have publish post on "directory" post type. hidden link
I believe this is a list of all the users that 'do' have a directory post. I am not sure where to filter or change so that is shows the ones that 'do not'. I have looked up a few of these users and they do have a listing.
Ahh ok. To display the list of users who "Do Not Have" post with post type "directory".
I've adjusted the code added to "Custom Code" section as given under:
add_filter( 'wpv_filter_user_query', 'func_filter_wihout_publish_posts_users',10,3);
function func_filter_wihout_publish_posts_users( $query_args, $view_settings, $view_id) {
global $wpdb;
if ( $view_id == 2578 ) {
//$query_args['has_published_posts'] = array('directory');
$users_having_posts = $wpdb->get_col($wpdb->prepare("SELECT $wpdb->users.ID FROM $wpdb->users INNER JOIN $wpdb->usermeta ON ( $wpdb->users.ID = $wpdb->usermeta.user_id ) WHERE 1=1 AND $wpdb->users.ID IN ( SELECT DISTINCT $wpdb->posts.post_author FROM $wpdb->posts WHERE $wpdb->posts.post_status = 'publish' AND $wpdb->posts.post_type IN ( 'directory' ) ) AND (
(
( $wpdb->usermeta.meta_key = 'mzd_capabilities' AND $wpdb->usermeta.meta_value LIKE '%\"contributor\"%' )
)) ORDER BY $wpdb->users.user_login ASC"));
$query_args['exclude'] = $users_having_posts;
}
return $query_args;
}
And When I see the list, I can confirm that it lists all users who do not have post created with post type "directory":
=> hidden link
My issue is resolved now. Thanks for your help, I am not sure how I would have known how to do all that custom coding, is there documentation on creating these query statements?
This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.