Store members in custom taxonomy or native user?
Store members in custom taxonomy or native user?
Store members in custom taxonomy or native user?
The only argument you get on user_register is the user ID. add_action( ‘user_register’, function( $user_id ) { echo $user_id; }); Maybe there is an error in your code?
get all data from DB1( non-wp-database ) and save to an $array. Use this wordpress code inside your functions.php for insert users into DB2 ( wordpress database). function cxg_wp_insert_user() { foreach ( $array as $arr ) { $user_data = array( ‘ID’ => ”, ‘user_pass’ => wp_generate_password(), ‘user_login’ => $loginName, ‘user_nicename’ => $nicename, ‘user_url’ => ”, … Read more
Here is how I would do it: function save_extra_user_profile_fields( $user_id ) { if (!isset($_POST[‘address’]) || empty($_POST[‘address’])) { // this field was not set or was empty // do your action wp_redirect( home_url() ); // or profile page exit; } else { // field was set and contains a value // do your action update_user_meta( $user_id, … Read more
Well, Roles are in many ways custom user types and you can add meta fields specific to roles. For example… function is_my_user_role($id = null) { global $profileuser; if (empty($profile) && !empty($id)) $profileuser = get_user_to_edit($id); return (in_array(‘myrole’,$profileuser->roles)) ? true : false; } function my_user_fields($profileuser) { if (!is_my_user_role()) return false; // HTML for the fields } add_action(‘show_user_profile’, … Read more
I feel the best way to do is add two options Body weight and Body fat(%) in the user profile, and then you can show it with the user logged from the db. I guess this would be a simpler way.
You could filter get_blogs_of_user and add this particular blog to the returned list. Pseudo-code, not tested: add_filter( ‘get_blogs_of_user’, ‘add_special_blog’, 10, 3 ); function add_special_blog( $blogs, $user_id, $all ) { $new_blog = get_blog_details( $special_blog_id ); $blogs[ $special_blog_id ] = (object) array( ‘userblog_id’ => $special_blog_id, ‘blogname’ => $new_blog->blogname, ‘domain’ => $new_blog->domain, ‘path’ => $new_blog->path, ‘site_id’ => $new_blog->site_id, … Read more
One way to do it is by creating a CPT for user profiles, and creating one “post” of that type per each user. Remove the user’s ability to add or remove osts and let him edit that post. This will make searching easier as you simply restrict the search for the specific CPT.
Are there any hook or filter when adding new user in WordPress?