nbiz
Forum Replies Created
-
Forum: Plugins
In reply to: Hide media upload, library tabs, leave URL tabHi WP_Dummy,
Thanks for the follow up. I have modified code and it still did not work initially.
But, here is what I found:
1. I gave the test user the permission (edit_others_posts) but it still didn’t work.
2. I deleted this section and now it does work:
if( is_admin() && !current_user_can(‘edit_others_posts’) ) ….. but, now it applies to admins also.
Is there a way to apply this based on user roles (vendor pro, business pro, etc.?) I use s2 member to create user roles.
Thanks again for your help.
Forum: Plugins
In reply to: Hide media upload, library tabs, leave URL tabHi WP_Dummy, thanks for the input. I have made the changes, but still the changes appear on the ‘posts’ admin page but not the ‘vendors’ admin page. Here is the code:
// Show only posts and media related to logged in author add_action('pre_get_posts', 'query_set_only_author' ); function query_set_only_author( $wp_query ) { global $current_user; if( is_admin() && !current_user_can('edit_others_posts') ) { $wp_query->set( 'author', $current_user->ID ); add_filter('views_edit-post', 'fix_post_counts'); add_filter('views_upload', 'fix_media_counts'); } } // Fix post counts function fix_post_counts($views) { global $current_user, $wp_query; unset($views['mine']); $types = array( array( 'status' => NULL ), array( 'status' => 'publish' ), array( 'status' => 'draft' ), array( 'status' => 'pending' ), array( 'status' => 'trash' ) ); foreach( $types as $type ) { $query = array( 'author' => $current_user->ID, 'post_type' => 'vendors', 'post_status' => $type['status'] ); $result = new WP_Query($query); if( $type['status'] == NULL ): $class = ($wp_query->query_vars['post_status'] == NULL) ? ' class="current"' : ''; $views['all'] = sprintf(__('<a href="%s"'. $class .'>Todas <span class="count">(%d)</span></a>', 'all'), admin_url('edit.php?post_type=vendors'), $result->found_posts); elseif( $type['status'] == 'publish' ): $class = ($wp_query->query_vars['post_status'] == 'publish') ? ' class="current"' : ''; $views['publish'] = sprintf(__('<a href="%s"'. $class .'>Publicadas <span class="count">(%d)</span></a>', 'publish'), admin_url('edit.php? post_status=publish&post_type=vendors'), $result->found_posts); elseif( $type['status'] == 'draft' ): $class = ($wp_query->query_vars['post_status'] == 'draft') ? ' class="current"' : ''; $views['draft'] = sprintf(__('<a href="%s"'. $class .'>Borrador'. ((sizeof($result->posts) > 1) ? "s" : "") .' <span class="count">(%d)</span></a>', 'draft'), admin_url('edit.php?post_status=draft&post_type=vendors'), $result->found_posts); elseif( $type['status'] == 'pending' ): $class = ($wp_query->query_vars['post_status'] == 'pending') ? ' class="current"' : ''; $views['pending'] = sprintf(__('<a href="%s"'. $class .'>Pendiente <span class="count">(%d)</span></a>', 'pending'), admin_url('edit.php?post_status=pending&post_type=vendors'), $result->found_posts); elseif( $type['status'] == 'trash' ): $class = ($wp_query->query_vars['post_status'] == 'trash') ? ' class="current"' : ''; $views['trash'] = sprintf(__('<a href="%s"'. $class .'>Papelera <span class="count">(%d)</span></a>', 'trash'), admin_url('edit.php?post_status=trash&post_type=vendors'), $result->found_posts); endif; } return $views; }
Forum: Plugins
In reply to: Hide media upload, library tabs, leave URL tabHi, pcserveis,
Is it possible to apply your code to custom post types?
I have a several custom posts types
example (vendors) post_type=vendors
I tried simply replacing the post_type=post with post_type=vendors but site goes blank on refresh.
Any help is appreciated.
I’m using the paid jwplayer and would like to get this working …. any help is appreciated.
Thanks.
Here is the link to pastebin …. thx