How to only show posts assigned to current user, only in certain post types

Roles and capabilities are used to control access and normally you should use them. For example, capabilities edit_other_posts and edit_published_posts are needed to edit other user’s posts. It’s the same with othe types (pages -> edit_other_pages, edit_published_pages). Since, besides limiting the right to change other user’s posts, you also want them to be invisible, you … Read more

Remove Order List Row Link in WooCommerce Admin?

Based on class-wc-admin-list-table-orders.php (order column on line 173) there doesn’t seem to be a filter to change the markup. To circumvent this, perhaps you could add a js/jQuery script, to admin_footer or with admin_enqueue_scripts, which either adds the necessary class(es), removes href or changes it to #, or with some event delegation wizardry have your … Read more

creating custom rewrite rules for admin pages

How would I setup a custom rewrite rule to redirect /wp-admin/(page-slug).php to /wp-admin/admin.php?page=(page-slug) You can’t, WP Admin doesn’t make use of the rewrite rules system like the frontend, so rewrite rules have no effect on WP Admin pages. You can only use WP rewrite rules to map pretty URLs on to versions that take the … Read more

Add column and post filter for a custom post type field on the edit.php page

First couple of handy helper functions, function my_custom_post_type() { return ‘post’; // edit this } function custom_field_status_metakey() { return ‘status’; } function custom_field_status_options() { return array( ” => __( ‘All statuses’, ‘textdomain’ ), // edit text domains ‘open’ => __( ‘Open’, ‘textdomain’ ), ‘closed’ => __( ‘Closed’, ‘textdomain’ ), ); } Add your custom column … Read more

Access $post object when adding custom columns to list table

You don’t need a global $post object, WP gives the column callback the post ID, which is all that is needed. Looking at this question/answer, we see this code: add_filter( ‘manage_book_posts_columns’, ‘set_custom_edit_book_columns’ ); function set_custom_edit_book_columns($columns) { …. $columns[‘publisher’] = __( ‘Publisher’, ‘your_text_domain’ ); return $columns; } add_action( ‘manage_book_posts_custom_column’ , ‘custom_book_column’, 10, 2 ); function custom_book_column( … Read more

Can I mass change all admin emails for a multisite instance?

Okay so thanks to the suggestion from Rup I got this to work and apply to all my sites locally (will double check this before using on live!) $blogs = get_sites([‘public’ => 1, ‘orderby’ => ‘registered’, ‘order’ => ‘DESC’, ‘number’ => 1000]); foreach($blogs as $blog) { $bid = $blog->blog_id; switch_to_blog($bid); update_option( ‘admin_email’, ‘[email protected]’ ); update_option( … Read more

SQL Query to Update Admin Email

While your SQL query will probably do the trick, you don’t need to interface directly with the database to accomplish this. The preferred methods would by using WordPress’ update_option() function or by running the WP-CLI command:wp option update. Via update_option() To override the admin email change confirmation process, add the following to your functions.php file … Read more