Register visits of my pages in wordpresss

It’s not a good idea to store user’s data on a file that is publicly accessible. A better way would be to create a folder, and store your file under it. Also, it’s better to use WordPress’s filesytem class rather than directly using PHP’s built-in functions. Here’s a quick fix: function wpse381320_after_login( $atts ) { … Read more

Display WordPress commenter nice name

wp_get_current_commenter() returns an array, the entry ‘comment_author’ stores the name: Array ( [‘comment_author’] => ‘Harriet Smith, [‘comment_author_email’] => ‘hsmith@,example.com’, [‘comment_author_url’] => ‘http://example.com/’ ) More information is available in the codex. Update To find the nice name, ask the DB: /** * Searches the user table by display name. * @param string $display_name * @return object … Read more

delete_user_meta : how to delete all the metadata of a given user (witout SQL)

Yes, it does delete the usermeta. Here’s the code it uses: $meta = $wpdb->get_col( $wpdb->prepare( “SELECT umeta_id FROM $wpdb->usermeta WHERE user_id = %d”, $id ) ); foreach ( $meta as $mid ) delete_metadata_by_mid( ‘user’, $mid ); There’s identical code in wp_delete_user (for the non-multisite case) and they use the same pattern for deleting taxonomy metadata, … Read more

disable column on post and user list

You can use the manage_{$screen->id}_columns hooks for this. To manage user columns we can use manage_users_columns which is passed an array of columns and whatever we don’t want we can unset(). /** * Manage User Admin Display Table Columns * * @param Array $columns * [cb] => <input type=”checkbox” /> * [username] => Username * … Read more

How can I retrieve current user id within wordpress plugin?

You probably called it too early, get_current_user_id uses wp_get_current_user, so move all your code that’s at the top level of functions.php into the init hook or appropriate equivalent. The only thing that should be in the global scope in your functions file if you want maximum compatability and efficiency is add_action and add_filter calls