• Resolved redwiper

    (@redwiper)


    Hi there. I have two login forms for two roles(members , case study) and to links for login and registration in navbar. Why user with role for example member can login with link(page) in navigation for case study and vise versa? It should be that user with login parameters and role for example member can access just in one login link-form for that role and vise versa.

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Support andrewshu

    (@andrewshu)

    Hello @redwiper

    Users can login from any login forms. Sorry, but this is how it works now.

    Regards.

    @redwiper

    You can replace the UM login shortcode with this shortcode:

    [select_login_form member_form_id="385" user_form_id="3687"]

    This code snippet will use one of the forms for login.

    member_form_id if the URL has a member parameter like
    https://domain.com/login/?member=true

    and the user_form_id in all other cases.

    add_shortcode( 'select_login_form', 'custom_select_login_form', 10, 2 );
    
    function custom_select_login_form( $attrs, $content ) {
    
        $login_form_id = false;
        if ( isset( $_REQUEST['member'] ) && isset( $attrs['member_form_id'] )) {
            $login_form_id = sanitize_text_field( $attrs['member_form_id'] );
        } else {
            if ( isset( $attrs['user_form_id'] )) {
                $login_form_id = sanitize_text_field( $attrs['user_form_id'] );
            }
        }
    
        if ( ! empty( $login_form_id ) && is_numeric( $login_form_id )) {
            if ( version_compare( get_bloginfo( 'version' ), '5.4', '<' ) ) {
                echo do_shortcode( '[ultimatemember form_id="' . $login_form_id . '"/]' );
            } else {
                echo apply_shortcodes( '[ultimatemember form_id="' . $login_form_id . '"/]' );
            }
        }
    }

    Install the code snippet into your active theme’s functions.php file
    or use the “Code Snippets” plugin.

    https://wordpress.org/plugins/code-snippets/

    Plugin Support andrewshu

    (@andrewshu)

    Hi @redwiper

    This thread has been inactive for a while so we’re going to go ahead and mark it Resolved.

    Please feel free to re-open this thread if any other questions come up and we’d be happy to help. 🙂

    Regards

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

The topic ‘Multiple custom login forms’ is closed to new replies.