Programatically change post author
It shouldn’t be any problem. Try this: $arg = array( ‘ID’ => $post_id, ‘post_author’ => $user_id, ); wp_update_post( $arg );
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.
Simply use add_post_type_support: add_action(‘init’, ‘wpse_74054_add_author_woocommerce’, 999 ); function wpse_74054_add_author_woocommerce() { add_post_type_support( ‘product’, ‘author’ ); } User assigned with custom role Authors enabled in Products post type Another option, which I’m not sure of its correctness, it to hook into woocommerce_register_post_type* and register the post type first. This is a copy of the original function plus … Read more
Try this code. $author = get_user_by( ‘slug’, get_query_var( ‘author_name’ ) ); echo $author->ID; Alternatively, if author name has not been set use: if ( $author_id = get_query_var( ‘author’ ) ) { $author = get_user_by( ‘id’, $author_id ); } credit @AndyAdams in the easily missed comments bellow
This is a simple hack I wrote in a similar situation. It will display all the Subscribers in the Author dropdown on edit/add post/page, from where you can select any one you want. I think it should work for you… add_filter(‘wp_dropdown_users’, ‘MySwitchUser’); function MySwitchUser($output) { //global $post is available here, hence you can check for … Read more
The above answer is good, but if redirecting to home page, it should specify a 301 status and exit after. add_action(‘template_redirect’, ‘my_custom_disable_author_page’); function my_custom_disable_author_page() { global $wp_query; if ( is_author() ) { // Redirect to homepage, set status to 301 permenant redirect. // Function defaults to 302 temporary redirect. wp_redirect(get_option(‘home’), 301); exit; } } wp_redirect() … Read more
I would use transients to do this: create a user-online-update function that you hook on init; it would look something like this: // get the user activity the list $logged_in_users = get_transient(‘online_status’); // get current user ID $user = wp_get_current_user(); // check if the current user needs to update his online status; // he does … Read more