How to change user role using hook

Please edit your function and add code used below for adding user role in functions.php This is basic idea how roles can be added and removed and how you can check your filed values. Please use according to your requirements. add_action( ‘profile_update’, ‘my_profile_update’, 10, 2 ); function my_profile_update( $user_id, $old_user_data ) { // here you … Read more

action user_new_form param is a string

use like this: $id = $user->ID; And if user is new set $id = 9999 function my_show_extra_profile_fields( $user ) { if(is_string($user) === true){ $user = new stdClass();//create a new $id = -9999; } $newsletter = esc_attr( get_the_author_meta( ‘_newsletter’, $id ) ); unset($user); }

Let Users Choose Post Categories

First, you will have to add the categories to user profiles. This question has been addressed before. That will give you the possibility to retrieve an array $data with the category ID’ a user is interested in. Now, you will need to turn that array into a list of posts. Depending on where you want … Read more