Hot answers tagged

1

You probably want to use wp_get_current_user to find out which user is browsing the site. $current_user = wp_get_current_user(); echo 'User ID: ' . $current_user->ID . '<br />'; From there you'll use the ID to pull the user's metadata with get_user_meta. $all_meta_for_user = get_user_meta( $current_user->ID ); echo 'User Description: ' . $...


1

Looks to me you should be seeking a woocommerce purchase completion hook. This would be when you could add that a donation has been made and at what amount, then you could grab any user information, amounted donated and other info you need and save it to your donor table. use this: add_action('woocommerce_order_status_completed', 'save_to_donors',10,1); ...


1

This action hook allows you to access data for a new user immediately after they are added to the database. The user id is passed to hook as an argument. Not all user meta data has been stored in the database when this action is triggered. For example, nickname is in the database but first_name and last_name. The password has already been encrypted when ...


1

Since the paste has worked perfect for you, let me turn it into an answer. You can always get the author of a given post with certain methods, let's use get_post_field( 'post_author', $post_id ) for this. To get the data of a given user, there's get_userdata() function to use. We'll pass the author ID as first param to this function to get the author data ...


1

The global $authordata variable is only available by default when $wp_query->is_author() && isset($wp_query->post) condition is satisfied. It means that you can't access $authordata inside a single post page. You may try to get author data via $wp_query: add_action('wp_head', function() { global $wp_query; $userdata = get_userdata(...


1

The function's arguments are as follows: user ID, custom field name (meta key), data return method (optional). So if you wanted to grab data in usermeta with the key of 'member_zip_code', you would run: get_user_meta( $user_id, 'member_zip_code', true ); Alternatively, in your prior method, you could grab the additional data like this: $data = ...


1

I think you should use wp-api functions which will do everything for you. get_users() function will get all users data just define fields which u require. get_user_meta() function will get usermeta data. $users = get_users( array( 'fields' => array( 'ID' ) ) ); foreach($users as $user_id){ print_r(get_user_meta ( $user_id->ID)); }



Only top voted, non community-wiki answers of a minimum length are eligible