Replies
- 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
- Tosin on June 19, 2021 at 6:52 pm in reply to: [Resolved] Add roles to users on new registration and first login #39199
Thank you brajesh
Please can you check the rough code
Also the code should not affect administrators (Admins should be excluded)
/** * Change user role on first login * */ function buddydev_change_user_role_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 ) ) { get_user_by('id', $user_id)->set_role('active member'); } } add_action( 'wp_login', 'buddydev_change_user_role_on_first_login', -1, 2 );Thanks
This might help I use this plugin to extend user login session https://wordpress.org/plugins/remember-me-controls/
- Tosin on June 4, 2021 at 3:22 pm in reply to: [Resolved] Buddypress moderation button shortcode #38945
Thanks
But now how will I output the button in a custom location inside my theme files using maybe do shortcode to output the button.
- Tosin on June 4, 2021 at 12:52 pm in reply to: [Resolved] Buddypress moderation button shortcode #38942
ok noted ive removed the code
thanks
- Tosin on June 3, 2021 at 11:31 am in reply to: [Resolved] Buddypress moderation button shortcode #38929
The code messed up this page https://www.nigerpress.com/archive/ the code should not show or display blog post archive pages for posts and other custom post types. The button should only display in the title of single posts and single adverts.
The button is also displaying in menu
see link for example https://www.nigerpress.com/article/business-palm-oil-saga/The button is also not showing in the custom post type advert see https://www.nigerpress.com/advert/high-quality-traditional-clothing-wares/