Replies
I want to use the two conditions to identify inactive user
1. User’s role should be (subscriber)
2. The inactivity state used by BuddyPress ()Thanks
Reminder: Any update on this sir
Thanks
Gentle reminder sir
Thanks
Can you please help provide a safe solution to this. I would feel much safer with your own code.
Thank you
- Tosin on June 26, 2021 at 3:55 pm in reply to: [Resolved] Add roles to users on new registration and first login #39288
This worked perfectly
Thank you very much Brajesh, thanks to you my site is now 90% complete im really grateful
- Tosin on June 26, 2021 at 1:28 pm in reply to: [Resolved] Add roles to users on new registration and first login #39279
Hello Brajesh,
I just found out why the code is not working, its conflicting with the other redirect code on first login. when I removed the redirect code it worked perfectly see code causing conflict.
function buddydev_redirect_on_first_login( $user_login, $user ) { if ( ! function_exists( 'buddypress' ) ) { return; } // check for user's last activity. $last_activity = bp_get_user_last_activity( $user->ID ); if ( empty( $last_activity ) ) { update_user_meta( $user->ID, '_buddydev_first_login', 1 ); // Redirect you custom page. bp_core_redirect( bp_get_root_domain() . '/welcome/' ); } elseif ( get_user_meta( $user->ID, '_buddydev_first_login', true ) ) { delete_user_meta( $user->ID, '_buddydev_first_login' ); // Try second login here. bp_core_redirect( bp_get_root_domain() . '/publish/' ); } } add_action( 'wp_login', 'buddydev_redirect_on_first_login', -1, 2 );
How can this conflict be prevented.
Thanks
- Tosin on June 24, 2021 at 9:18 pm in reply to: [Resolved] Add roles to users on new registration and first login #39258
Thank you Brajesh, I will be expecting your feedback.
- Tosin on June 22, 2021 at 9:04 am in reply to: [Resolved] Add roles to users on new registration and first login #39220
(active_member) is the new custom role I created using this plugin https://wordpress.org/plugins/members/
- Tosin on June 22, 2021 at 4:17 am in reply to: [Resolved] Add roles to users on new registration and first login #39213
I tried the code but it did not change newly registered role on first login to active_member, I also tried using the code below but it also did not work
if ( empty( $last_activity ) ) { $active_role = 'active_member'; $non_active_role = 'non_active_member'; $user->remove_role( $non_active_role ); $user->add_role( $active_role ); }
I don’t know if this has any relevance
wp_update_user
- Tosin on June 21, 2021 at 2:22 pm in reply to: [Resolved] Add roles to users on new registration and first login #39208
Gentle reminder
Thanks