Skip to:
Content
Pages
Categories
Search
Top
Bottom

Forum Replies Created

Viewing 21 replies - 1 through 21 (of 21 total)
  • @flamuren

    Participant

    Thank you πŸ™ (that was a desperate note – sorry)

    @flamuren

    Participant

    @emaralive thanks and I am aware.

    I thought perhaps someone kind would look at it and see what in the redirect goes wrong and perhaps its something easy for a coder.

    All the other text is for context to make it easier to understand what I am trying to do.

    I mean I can listen to the AI-models and just split the code and put a filter in the function file. But something in me says there must be some way to redirect to your own messages after login with prefilled “send to” value. It feels like something that buddypress would be able to handle nativly?

    @flamuren

    Participant

    Hi,

    did you manage to solve this? I am asking the same thing, but for a usertype (“employer” from WPJM plugin).

    Best regards,

    flamuren

    @flamuren

    Participant

    I wrote this code in the child function file but it wont work. Any suggestion what might be wrong?

    function my_custom_bp_employer_features_setup() {
        add_action( 'bp_members_directory_tabs', 'my_custom_members_directory_employer_tab', 10 );
        add_filter( 'bp_pre_user_query_args', 'my_custom_members_directory_filter_by_role' );
        add_action( 'wp_head', 'my_custom_members_directory_employer_tab_styles' );
    }
    add_action( 'bp_loaded', 'my_custom_bp_employer_features_setup' );
    
    function my_custom_members_directory_employer_tab() {
        error_log( 'my_custom_members_directory_employer_tab: Attempting to add "Arbetsgivare" tab.' );
        if ( ! function_exists( 'buddypress' ) || ! bp_is_active( 'members' ) ) {
            error_log( 'my_custom_members_directory_employer_tab: BuddyPress or Members component not active.' );
            return;
        }
        bp_members_add_tab( array(
            'id'                => 'employer',
            'text'              => __( 'Arbetsgivare' ),
            'slug'              => 'employer',
            'link'              => bp_get_members_directory_permalink() . 'employer/',
            'position'          => 35,
            'css_id'            => 'members-employer-tab',
            'screen_function'   => 'my_custom_members_directory_employer_screen',
            'show_in_filters'   => true,
            'filter_id'         => 'employer',
        ) );
        error_log( 'my_custom_members_directory_employer_tab: Successfully called bp_members_add_tab().' );
    }
    
    function my_custom_members_directory_employer_screen() {
        error_log( 'my_custom_members_directory_employer_screen: Screen function called.' );
        bp_core_load_template( 'members/index' );
    }
    
    function my_custom_members_directory_filter_by_role( $query_args ) {
        error_log( 'my_custom_members_directory_filter_by_role: Filter applied.' );
        if ( bp_current_action() === 'employer' ) {
            error_log( 'my_custom_members_directory_filter_by_role: Filtering by "employer" role.' );
            $query_args['role'] = 'employer';
        }
        return $query_args;
    }

    @flamuren

    Participant

    go to wp admin/dashboard – settings – buddypress – settings – and here you should have settings to adjust how registrations are handled.

    I cant confirm since I have official registration set to active. But if I remember you can set your settings to either manual or automatic here.

    Please try and confirm πŸ™‚

    @flamuren

    Participant

    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

    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

    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

    I found it here:

    Stop BuddyPress SPAM

    @flamuren

    Participant

    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

    Solved it by coying the code from another install.

    @flamuren

    Participant

    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

    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

    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

    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

    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

    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

    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

    Participant

    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

    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 21 replies - 1 through 21 (of 21 total)
Skip to toolbar