Update user counts in admin interface

After searching I created a hook for that and that hook is: add_filter(“views_users”, ‘custom_editor_counts’, 10, 1); function custom_editor_counts($views) { $view=$views; if ( current_user_can( ‘contributor’ ) ) { unset($views[‘all’]); unset($views[‘administrator’]); unset($views[‘subscriber’]); unset($views[‘customer’]); unset($views[‘contributor’]); unset($views[‘shop_manager’]); return $views; }else{ $views=$view; return $views; } } This works for me.

Query for post term that matches user ID

Try this code it will surely work, before testing this code make sure you have added the categories title as numbers. $terms = get_terms( array( ‘taxonomy’ => ‘list’, ‘hide_empty’ => false )); $user = wp_get_current_user(); if(!empty($terms)){ foreach ( $terms as $term ) { if($term->name == $user->ID){ // Do something } } } This code will … Read more

wp_insert_user always tries the same user name

Before doing anything, make sure that the user account doesn’t already exist. This is really easy to do with the username_exists function. if( null == username_exists( $username ) ) { echo “user not exist”; } use the above code and see what happen then do as below $user_id = wp_create_user ( $email_address, $password, $email_address ); … Read more

Redirect /member/ to /member/user

You could hook into template_redirect action hook and redirect the users. I assume that you want to redirect the currently logged in user. add_action( ‘template_redirect’, ‘wpse314345_redirect_users’ ); function wpse314345_redirect_users( $template ){ // Check if the user is logged in if( is_user_logged_in() ) { // Get the current user $user = wp_get_current_user(); // Redirect the user … Read more

Disabling user capability to edit_posts or delete_posts in the front-end

By using this functionality we can able to remove the delete option of the page or post. function wp_restrict_page_deletion( $caps, $cap, $user_id, $args ) { $post_id = $args[0]; if ( $cap === ‘delete_post’ && $post_id === your post id* ) { $caps[] = ‘do_not_allow’; } return $caps; } add_filter( ‘map_meta_cap’, ‘wp_restrict_page_deletion’, 10, 4 ); I … Read more

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