Change users.php WP_User_Query

pre_get_users is the action that is fired before a user query is run. You need to check the context of the action to make sure you’re on the main users screen. You can then alter the query with any parameters accepted by WP_User_Query. A quick example: function wpd_filter_users( $query ) { $screen = get_current_screen(); if( … Read more

Admin sometimes redirects to HTTPS

Finally, after MONTHS I was able to solve it. Just add $_SERVER[‘REQUEST_SCHEME’] = ‘http’; $_SERVER[‘SERVER_PORT’] = 80; To wp-config.php, preferably before calling wp-settings.php Thanks to Daan Meijer for this. PS: It was a server-side error, probably something to do with PHP process manager such as php-fpm or mod_php. The hosting company solved it without the … Read more

“Add New” button on custom post type grid

As per comments you likely you want to use native editor rather than build one from scratch. From poking through the core source outputting the link for that would be along the lines of: $post_new_file = “post-new.php?post_type=$post_type” if ( isset( $post_new_file ) && current_user_can( $post_type_object->cap->create_posts ) ) echo ‘ <a href=”‘ . esc_url( admin_url( $post_new_file … Read more

Redirect an entire WordPress site on a subdomain, except wp-admin

Answering my own question for future reference. I couldn’t get a redirect to work with .htaccess, but found some helpful troubleshooting suggestions, mainly this one: https://stackoverflow.com/a/14116956/3218102. I ended up doing this with a modification to header.php and the functions wp_redirect and is_admin. This is the code I added to the top of header.php: <?php // … Read more

How do I change the hover (focus) color of admin bar from frontend?

switch your hook to [‘admin_bar_menu’] and make things !important. add_action( ‘admin_bar_menu’, ‘change_bar_color1’ ); function change_bar_color1() { ?> <style> #wpadminbar .ab-empty-item, #wpadminbar a.ab-item, #wpadminbar > #wp-toolbar span.ab-label, #wpadminbar > #wp-toolbar span.noticon { color: #FFFFFF !important; } #wpadminbar { background: #ff6000 !important; border-top: 2px solid #000000; border-bottom: 2px solid #000000; border-left: 2px solid #ff6000; border-right: 2px solid … Read more

Get current session in WP admin

Google is your friend. How to use session_start in WordPress? and How to use session in wordpress in plugin development It looks like your mistake is that you didn’t capitalise “Session” when you declare the variable. Instead of $_session[‘wp_nonce’], try $_SESSION[‘wp_nonce’].

Displaying Title in Title Tag on Edit page?

I found my the solution (filter hook admin_title) in Change page title in admin area function my_admin_title($admin_title, $title) { global $post, $action; if($action == ‘edit’ ) { $admin_title_tag = ‘* ‘ . $post->post_title; return $admin_title_tag; } } add_filter(‘admin_title’, ‘my_admin_title’, 10, 2);

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)