Skip to:
Content
Pages
Categories
Search
Top
Bottom

Forum Replies Created

Viewing 16 replies - 1 through 16 (of 16 total)

  • flamuren
    Participant

    @flamuren

    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);

    flamuren
    Participant

    @flamuren

    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 πŸ™‚


    flamuren
    Participant

    @flamuren

    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 πŸ™


    flamuren
    Participant

    @flamuren

    I found it here:

    Stop BuddyPress SPAM


    flamuren
    Participant

    @flamuren

    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.


    flamuren
    Participant

    @flamuren

    Solved it by coying the code from another install.


    flamuren
    Participant

    @flamuren

    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.


    flamuren
    Participant

    @flamuren

    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


    flamuren
    Participant

    @flamuren

    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 πŸ™‚πŸ‘


    flamuren
    Participant

    @flamuren

    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.


    flamuren
    Participant

    @flamuren

    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.


    flamuren
    Participant

    @flamuren

    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.


    flamuren
    Participant

    @flamuren

    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.


    flamuren
    Participant

    @flamuren


    flamuren
    Participant

    @flamuren

    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 πŸ™


    flamuren
    Participant

    @flamuren

    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? πŸ€”

Viewing 16 replies - 1 through 16 (of 16 total)
Skip to toolbar