the_author() returns empty string
Any reason this is commented out? //setup_postdata($post); This function setups global variables for current post and author data is pulled from one of those.
Any reason this is commented out? //setup_postdata($post); This function setups global variables for current post and author data is pulled from one of those.
Maybe you can try adding your condition directly in the query string, using something like this function wpse_29570_where_filter($where){ global $wpdb; if( is_search() ) { $search= get_query_var(‘s’); $query=$wpdb->prepare(“SELECT user_id FROM $wpdb->usermeta WHERE ( meta_key=’first_name’ AND meta_value LIKE ‘%%%s%%’ ) or ( meta_key=’last_name’ AND meta_value LIKE ‘%%%s%%’ )”, $search ,$search); $authorID= $wpdb->get_var( $query ); if($authorID){ $where = … Read more
There is no special hook to author change. But you can achieve it by using post_updated hook. Example: add_action(‘post_updated’, ‘prefix_on_update_author’, 10, 3); function prefix_on_update_author($post_ID, $post_after, $post_before) { if ($post_after->post_author != $post_before->post_author) { // author has been changed // you can add your own hook here or write your code } } Here is the codex … Read more
Every registered user can have profile, they don’t need to have posts. To change WordPress author’s profile permalink, paste the following code in your functions.php: function change_author_permalink_base() { global $wp_rewrite; $wp_rewrite->author_base = “user”; } add_filter( ‘init’, ‘change_author_permalink_base’ ); After pasting the code, visit Settings->Permalink Structure under your wordpress admin, to flush the rewrite rules. This … Read more
By the looks of it, there’s a plugin to achieve exactly this, so save you rolling your own for it. The plugin is: https://wordpress.org/plugins/permalinks-customizer/ I installed it to test that it does what you’re looking for. Here’s a screenshot that shows what you’d do:
This is a little tricky because sanitize_user allows spaces in usernames, meaning it difficult to avoid grabbing the whole phrase ‘@johndoe said that … ‘ as opposed to just the actual username ‘@johndoe’ and you have no separator at the end that would help. To avoid that I imposed a requirement that spaces in the … Read more
You can’t achieve this easily with WP’s built-in search system. Even if you managed to build a complicated query that pulls data from the user table, it would be incredibly slow. Search Unleashed had this functionality, but I’m not sure about compatibility with WP 3.2. I used it in the past as inspiration to add … Read more
you need 3 simple functions and hooks first change the author base: //change author/username base to users/userID function change_author_permalinks() { global $wp_rewrite; // Change the value of the author permalink base to whatever you want here $wp_rewrite->author_base=”users”; $wp_rewrite->flush_rules(); } add_action(‘init’,’change_author_permalinks’); then add users to query_vars: add_filter(‘query_vars’, ‘users_query_vars’); function users_query_vars($vars) { // add lid to the … Read more
It shouldn’t be any problem. Try this: $arg = array( ‘ID’ => $post_id, ‘post_author’ => $user_id, ); wp_update_post( $arg );
remove the filter that formats the description. put this in your theme’s functions.php: remove_filter(‘pre_user_description’, ‘wp_filter_kses’); EDIT – I should mention, if you allow random people to register and add their own bio for display on the site, not filtering that text could enable bad things.