Reviews/Add Listings Login and Register Links

This topic contains 4 replies, has 3 voices, and was last updated by  Naveen Giri 4 years ago.

We have moved to a support ticketing system and our forums are now closed.

Open Support Ticket
  • Author
    Posts
  • #538194

    gaz36f
    Expired Member
    Post count: 54

    I have Ultimate Member installed and it works very well with Geodirectory, except in one important way; the login/regiser reminder link for non-logged-in users to post reviews or add listings are directed to the core wordpress login page rather than the UM login page.

    I have raised this with UM and they suggested the following snippet code:

    add_filter( 'comment_form_defaults', function( $fields ) {
        if( ! function_exists("um_get_core_page") ) return $fields; 
     
        $fields['must_log_in'] = sprintf( 
            __( '<p class="must-log-in">
                     You must Register or 
                     Login to post a comment.</p>' 
            ),
            um_get_core_page("register"),
             um_get_core_page("login")."?redirect_to=". apply_filters( 'the_permalink', get_permalink() ) 
        );
        return $fields;
    });

    But it doesn’t work. Any suggestions please?

    Thanks, Gary

    #538202

    Kor
    Moderator
    Post count: 16516

    Hi Gary,

    Thanks for your post. I will forward this to a developer for a quick review.

    #538231

    Naveen Giri
    Moderator
    Post count: 1559

    Hi gaz36f,

    I have added some changes in the code snippet.
    Please check now.

    
    
    
    add_filter( 'geodir_review_form_args', function( $fields ) {
    
        if( ! function_exists("um_get_core_page") ) return $fields; 
        $fields['must_log_in'] = sprintf( 
            __( '<p class="must-log-in">
                     You must <a href="%s">Register</a> or 
                     <a href="%s">Login</a> to post a comment.</p>' 
            ),
            um_get_core_page("register"),
             um_get_core_page("login")."?redirect_to=". apply_filters( 'the_permalink', get_permalink() ) 
        );
    
        return $fields;
    });
    
    
    
    
    add_filter( 'login_url', 'gd_ultimate_member_login_link', 10, 3 );
    /**
     * gd_ultimate_member_login_link the login URL.
     *
     * @since 2.8.0
     * @since 4.2.0 The <code>$force_reauth
     parameter was added.
     *
     * @param string $login_url    The login URL. Not HTML-encoded.
     * @param string $redirect     The path to redirect to on login, if supplied.
     * @param bool   $force_reauth Whether to force reauthorization, even if a cookie is present.
     *
     * @return string
     */
    function gd_ultimate_member_login_link($login_url, $redirect, $force_reauth ){
    	
    	if( ! function_exists("um_get_core_page") ) return $login_url;
    	$login_url = um_get_core_page("login")."?redirect_to=". apply_filters( 'the_permalink', get_permalink() );
    	
        if ( $force_reauth ) {
            $login_url = add_query_arg( 'reauth', '1', $login_url );
        }
    
    	return $login_url; 
    }
    

    Thanks

    #538432

    gaz36f
    Expired Member
    Post count: 54

    Fantastic! It works very well. Thank you so much Naveen. Best wishes, Gary

    #538532

    Naveen Giri
    Moderator
    Post count: 1559

    Thanks for confirming it, Gary.
    Have a great day.

Viewing 5 posts - 1 through 5 (of 5 total)

We have moved to a support ticketing system and our forums are now closed.

Open Support Ticket