Woocommerce: assign an “author” to a product

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

Echo author ID in author.php

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

Select subscriber as author of post in admin panel?

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

How to get a buddypress user profile link and a certain user profile field for the current post author?

For an author’s profile link, use bp_core_get_user_domain( $user_id ) to get the URL, and bp_core_get_userlink( $user_id ) to get an HTML link element, including display name. For the xprofile data, use xprofile_get_field_data( $field, $user_id ) $field can be either the name of the field (like ‘Biography’) or the numerical field id.

How to remove the author pages?

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

How to get Author ID outside the loop

The simplest and most straightforward way to get the post author ID outside the loop, if you know the post ID, is to use the WordPress core function get_post_field(). $post_author_id = get_post_field( ‘post_author’, $post_id ); If you do not yet know the post ID of the page you are on, then since WP 3.1 the … Read more

How to check if a user (not current user) is logged in?

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