Restrict editing of post type to list stored in user meta

What is the right action to invoke before a custom post type is getting edited in dashboard and contains the argument the post id? The url /wp-admin/post.php?post=282&action=edit&classic-editor here is what I try $userId = get_current_user_id(); $affiliate = get_field('field_627ff399b5ef6', 'user_' . $userId); $this->currentAffiliate = $affiliate; $subPages = get_children([ 'post_parent' => $affiliate[0]->ID, 'post_type' => 'affiliate', ]); $pageIds = collect($subPages)->pluck('ID')->push($affiliate[0]->ID)->toArray(); if edit page ID is not in $pageIds redirect to the not allowed screen
Category: Web

Create 3 buttons for new post for a different category

I am customizing the admin panel of WordPress. I have users with roles to only write to 3 categories. I would like to design 3 buttons or divs to create a new post but each one for a different category. That in the dashboard. I will have a different dashboard for role user Any idea?
Category: Web

Is there way to toggle the publish date display?

I am interested in changing our WP dashboard so that I can choose whether an individual Post will include the publish date or not. Is there a way to do it without a plug-in and insert code that maybe creates a checkmark or something like that in the Post dashboard that can toggle the publish date display? Thank you in advance!
Category: Web

Hide the wp-admin bar from dashboard

I want to hide the admin bar from dashboard. I tried with following code: add_action('after_setup_theme', 'remove_admin_bar'); function remove_admin_bar() { if (!current_user_can('administrator') && !is_admin()) { show_admin_bar(false); } } It hide the admin bar when a logged in admin visit as front-end user. I actually want to hide the admin bar from dashboard back-end as indicated by red arrow in the following picture: Any help is appreciated.
Category: Web

How to change the "Woocommerce Status" text in dashboard widget

I want to change the "Woocommerce Status" text in dashboard widget. See the image: I found this code in http://stackoverflow.com but it not working. function change_add_to_cart_message( $translated, $text, $domain ) { global $pagenow; if( $text === 'WooCommerce status' && $domain === 'woocommerce' && is_admin() && $pagenow === 'index.php' ){ $translated = __( 'WooCommerce summary', $domain ); } return $translated; } add_filter( 'gettext', 'change_add_to_cart_message', 10, 3 );
Category: Web

How can I view my site directly from WordPress dashboard?

Basically, I am using localhost through XAMPP, it has been 2 weeks since I started and and I had to reinstall XAMPP because I was having problems with ports. And now, I just started remaking my website again, using the port '3000' for apache and everything seemed to work fine until I can't even see the changed I have made from the wordpress dashboard or by just writing the domain name in the search bar, what is weird is that, …
Category: Web

Trying to access second site dashboard on a multisite configuration proceeds to an error

Having this issue that I create a sub-site and when I try to access the dashboard of that sub-site it leads to this error This page isn’t working domain.com redirected you too many times. Try clearing your cookies. ERR_TOO_MANY_REDIRECTS .htaccess #BEGIN WordPress <IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteRule ^index\.php$ - [L] #add a trailing slash to /wp-admin RewriteRule ^([_0-9a-zA-Z-]+/)?wp-admin$ $1wp-admin/ [R=301,L] RewriteCond %{REQUEST_FILENAME} -f [OR] RewriteCond %{REQUEST_FILENAME} -d RewriteRule ^ - [L] RewriteRule ^([_0-9a-zA-Z-]+/)?(wp-(content|admin|includes).*) $2 [L] RewriteRule ^([_0-9a-zA-Z-]+/)?(.*\.php)$ $2 …
Category: Web

After database migration, posts not showing up in dashboard

Transferring domains, I migrated a WordPress database using the export/import functions in phpmyadmin. Everything worked as intended, until I tried to change permalink appearance in the WP dashboard. Since then, all posts have disappeared from the Posts tab in the WP dashboard. The posts still exist in the DB. Measures I have tried already: Reimporting the DB from my backed up version. Changing permalink structure back to what it was originally. Running the WordPress database table repair protocol. (It reported …
Category: Web

Publish, Save Draft and Preview buttons do not work after being moved with jQuery

I'm trying to change the layout of the post-new.php page and as part of this I would like the publish, save draft and preview buttons below the form rather than to the right. So in my plugin js file I'm using jQuery.append() to move them into a custom that sits below the main . I'm moving the divs: #save-action, #preview-action and #publishing-action. This works fine layout-wise. However, now none of the buttons seem to perform their job. The publish button …
Category: Web

"My Sites" incorrectly showing all network sites for all logged in users

I've searched this board for a similar question and answer, and I haven't seen anyone ask about this. Recently, after some updates, the functionality of the "My Site" item on the WordPress nav has changed. We run multisite with users having different permissions for different sites on the network. Most content managers only have editing or admin privileges on one or two of the sites on the network, and have otherwise not been added as users to the sites they …
Category: Web

How to Arrange Posts by Size in the WordPress Dashboard?

This may be a lame question, but I can't find an answer to this. Let's say you have a ton of empty posts that you want to delete. Obviously those who have some content will have more size. Is there any option to sort posts by size in WordPress dashboard? Even better, is there any option to automatically prevent posts from beeing published without any content? Through fuctions.php maybe? Would appreciate your help!
Category: Web

Get post attached image to display in admin dashboard

I've searched awhile for a solution on how to get the attached image in the post's editor to display within the dashboard but I am running into an issue. I've seen how to do this and can do this with the thumbnail: function foo_attached_image( $post_ID ) { $post_thumbnail_id = get_post_thumbnail_id( $post_ID ); if ( $post_thumbnail_id ) { $post_thumbnail_img = wp_get_attachment_image_src( $post_thumbnail_id ); return $post_thumbnail_img[0]; } } but the thumbnail is already being used and has a different size then I …
Category: Web

Admin - Dashboard - Unset recent comments

I try to get rid of the comments list in the WordPress 4 dashboard section but it doesn't work. Here is what I tried: function remove_all_dashboard_widgets() { global $wp_meta_boxes; // these 2 are ok as they are not displayed anymore unset($wp_meta_boxes['dashboard']['side']['core']['dashboard_quick_press']); unset($wp_meta_boxes['dashboard']['side']['core']['dashboard_primary']); // I tried both "recent" and "latest comments" with no success unset($wp_meta_boxes['dashboard']['normal']['core']['dashboard_recent_comments']); unset($wp_meta_boxes['dashboard']['normal']['core']['dashboard_latest_comments']); // I also tried these two with no success remove_meta_box('dashboard_recent_comments', 'dashboard', 'core'); remove_meta_box('dashboard_latest_comments', 'dashboard', 'core'); } add_action('wp_dashboard_setup', 'remove_all_dashboard_widgets'); The Quick press and Primary boxes are …
Category: Web

How to create front-end (editable) Wordpress user profile pages?

So I am using Gravity Forms to create registration and login forms. But after the user logs in, I want them to be able to see a custom front-end profile page instead of the default Wordpress user dashboard. This page has to be catered based on the role the user signed up for. I want to refrain from using any plugins (other than Gravity Forms extensions) because this profile page has information that must be integrated with another plugin called …
Category: Web

Unable to login to admin dashboard after setting up multisite

I'm fairly new to WordPress and now having a problem with multisite set-up. I manage to follow the steps to get the code to add both to wp-config and .htaccess files, but after saving the changes and trying to login back to WordPress to continue setting subdomains up, I'm suddenly not able to login back to the admin view. I'm working on the localhost, and when I sign-on via http://localhost/wordpress/wp-admin/ I just end up seeing by blog UI, but now …
Category: Web

I want to add another search box on posts page in dashboard

There is already a search box in wordpress dashboard for posts, products, pages etc. in their listing page. My client use wordpress admin with their phone so he requested another search box on top of those pages with the same functionality. I can edit codes if I need to, but I don't know where to start. Have anybody needed that kind of behavior before? It seems easy but I don't know how to edit listing pages in wordpress dashboard.
Category: Web

WP-Admin shows (1) update but there is no update for plugin, theme or Wordpress

I am having a strange issue where in my wp-admin it says there is an update required. However I checked the Themes, Plugins and even reinstalled the latest version of Wordpress and it is still showing me the update. I have also deleted my cache plugin and done all sorts of other tasks to try to fix it but have no luck. Would anyone have any idea of what could be causing this and/or how I can fix this? It …
Category: Web

Cannot access to dashboard on localhost

while i am trying to migrate my WP website from to localhost, i changed the Host Name from Dashboard -->> Settings (WordPress/localhost ---> exp.00webhost.com) Now i want to access my website on localhost using the Dashboard when i connect to website i get this but when i tried to access another page i got the URL of 000webhost . Any idea on how to change this URL,while i have not the access to the dashboard Thank you in advance
Category: Web

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.