Forum Replies Created
-
OMG I am sooo happy! Chatgpt and some noob questions to it managed to tweak the code so now it works! π
If anyone would need it, this now works:
function assign_role_based_on_profile_field($user_id) { // Get the BuddyPress profile data for the registered user if (function_exists('xprofile_get_field_data')) { $role_value = xprofile_get_field_data('Roll', $user_id); // Replace 'Role' with the exact name of your profile field $user = new WP_User($user_id); // Assign the user role based on the profile field value if ($role_value == 'Arbetsgivare') { // Assign 'employer' role $user->set_role('employer'); // Replace 'employer' with the exact role slug } elseif ($role_value == 'ArbetssΓΆkande') { // Assign 'candidate' role $user->set_role('candidate'); // Replace 'candidate' with the exact role slug } else { // Default role if no specific selection is made $user->set_role('subscriber'); // Or any other default role } } } add_action('bp_core_activated_user', 'assign_role_based_on_profile_field', 10, 1);
I would really prefer not to use extra plugins for this small feature. Its only this small detail I want to fix – might need to pay a developer to sort it out π
Thanks for your help π
Thanks π It would work with a membership plugin to handle it. However it wont be able to use the WPJM roles: candidate or employer. WPJM plugins use these to allow different dashboards for the users depending on user roles.
If I would use a role/member plugin it would create new roles that would not be able to control this.
Thats why I would like for the code snippet to work and assign users the predesigned roles from WPJM for a more complete solution.
Hope this makes sense and that anyone would like to help. Its over my head π
I found it here:
found the menu items if I edit the user profile menu from the theme customizer.
Perhaps the theme is not compatible with the latest 12.4.0.
So not really any issue – just strange.
Solved it by coying the code from another install.
Just to clarify: when managing menues I dont have the “buddypress directories” or “buddypress-member” menu options.
So I cant add them to the menu.
They seem to have been removed on the latest 12.4.0. Since I have the exact same website installed a week before using 12.3.0 which have these menu options.
I found the file here on github, but it does not look the same, only one row of code (latest update 3 months ago). I use the latest update and it has two rows.
https://github.com/buddypress/buddypress/blob/master/src/bp-core/blocks/login-form/index.asset.php
Ok I see now that we use urls only. This is probably clever, but tricky to keep track of. Perhaps beginner time to adjust to it ππ
I can verify this. Has used buddypress before and when installing the installationguide created and assigned pages. Now I got nothing and was trying to figure out what to do. Found this thread so I am not alone.
I can verify this. Has used buddypress before and when installing the installationguide created and assigned pages. Now I got nothing and was trying to figure out what to do. Found this thread so I am not alone.
A quick update for others that are looking to do this.
I choose https://wordpress.org/plugins/lock-my-bp
Works great, easy to use and is 100% free. The only small issue as of now is a slight issue that the blog articales can be shown as not logged in – even if the blog page is locked. Hopefully the plugin creator will see this and make it work. But its a small issue really. Love the plugin.
Thanks for the code tip.
I also got this recommended for me: https://wordpress.org/plugins/lock-my-bp
I think with all these tips and plugins etc I will try some out and evaluate. I will try to remember to update this thread on what solution I go with and how it works.
Has anyone tried any of these plugins?
6 Best WordPress Restrict Content Plugins π 2023 (Free & Paid)
Thanks alot Venutius. Except for the bad reviews on that plugin it seems to be a good fit to try.
I will try to keep on google and look in the support forum, to do some more research as you propouse.
If anyone else have anything to recommend I am all ears π
Hi, this thread helped me fixed a question to get login page sorted – many thanks.
Just a follow up though. Is it possible to get a button/link to display on the login page to the “forgot password” page? π€