Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do I change URL links in a login | register button?

Status
Not open for further replies.

cleartango

IS-IT--Management
Mar 25, 2016
2
0
0
GB
Hi

I have a problem with my "login | register" / "username | logout" link on WP theme ‘LMS'. I need to change the URLs where they are pointing
As it is now, the login | register link works in the following way.


If logged out, it will show a login | register option. Clicking on it takes you to wp-login (using the S2member plugin in some way) which doesn’t collect the registration info I need

If logged in, it will show ‘username' and a ‘logout’ option. Clicking on the username takes you to an S2member account page which looks awful and doesn’t show the info I need to show.


I would like both links to point to different URLs.

If user is logged out and they click on 'login | register', then should take them to If user is logged in and clicks on username, then should take them to OR if they logout should take them to

The code I need to change is below. I know very little about php, but am keen to learn.

Would somebody be able to help and show me what I need to change?

Many thanks in advance

Mick



PHP:
<div class="header-register">                    
                        <ul>
<?php
                            if(!is_user_logged_in()): 
                                $login = dttheme_get_page_permalink_by_its_template('tpl-login.php'); 
                                $login = is_null($login) ? home_url()."/wp-login.php" : $login;
                            ?>
                                <li><a href="<?php echo $login; ?>" title="<?php _e('Login / Register Now', 'dt_themes');?>"><i class="fa fa-user"></i><?php echo __('Login', 'dt_themes').'<span> | </span>'.__('Register', 'dt_themes'); ?></a></li>
                            <?php
                            else:
                                $current_user = wp_get_current_user();
                                $welcome = dttheme_get_page_permalink_by_its_template('tpl-welcome.php');
                                if( dttheme_is_plugin_active('s2member/s2member.php') ):
                                    $login_welcome_page = get_option('ws_plugin__s2member_cache');
                                    $login_welcome_page = $login_welcome_page['login_welcome_page'];
                                    $page = $login_welcome_page['page'];
                                    if( !empty($page) ):
                                        $link = $login_welcome_page['link'];
                                        $title =  get_the_title($page);
                                        echo '<li><a href="'.$link.'">'.get_avatar( $current_user->ID, 30).'<span>'.__('Welcome, ', 'dt_themes').'&nbsp;'.$current_user->display_name.' | </span>'.'</a></li>';
elseif(!is_null($welcome)):
echo '<li><a href="'.$welcome.'">'.get_avatar( $current_user->ID, 30).'<span>'.__('Welcome, ', 'dt_themes').'&nbsp;'.$current_user->display_name.' | </span>'.'</a></li>';
                                    endif;
                                elseif(!is_null($welcome)):
                                    echo '<li><a href="'.$welcome.'">'.get_avatar( $current_user->ID, 30).'<span>'.__('Welcome, ', 'dt_themes').'&nbsp;'.$current_user->display_name.' | </span>'.'</a></li>';
                                else:
                                    echo '<li><a href="#">'.get_avatar( $current_user->ID, 30).'<span>'.__('Welcome, ', 'dt_themes').'&nbsp;'.$current_user->display_name.' | </span>'.'</a></li>';
                                endif;
                                                            
                                echo '<li><a href="'.wp_logout_url(get_permalink()).'" title="'.__('Logout', 'dt_themes').'">'.__('Logout', 'dt_themes').'</a></li>';
                            endif;

if(class_exists('WooCommerce') && dttheme_option('appearance', 'enable-header-cart')) {
global $woocommerce;
$cart_url = $woocommerce->cart->get_cart_url();
echo '<li class="dt-sc-cart"><a href="'.$cart_url.'"><i class="fa fa-shopping-cart"></i></a></li>';
}
                            ?>
                        </ul>
                    </div>
 
I think that you will find that you are looking in the wrong place.

For Wordpress, URLs are very rarely "hard wired" into the PHP code, they are in the various database tables or as DEFINES in configuration files and are retrieved via 'core' or 'theme' functions,

This for example.

$cart_url = $woocommerce->cart->get_cart_url();

Which "requests" a URL from the $woocommerce 'plugin' class properties and methods, and the class in turn in turn fetches the data from the woocommerce table structure.

Chris.

Indifference will be the downfall of mankind, but who cares?
Time flies like an arrow, however, fruit flies like a banana.
Webmaster Forum
 
Thanks Chris
The login | register link comes from the WP theme I have installed. The theme developers told me that I need to look at and edit this particular file.
The first half of the code seems to deal with login and welcome (which is the account page after the user has logged in)
Are you pretty sure the code I have provided doesn't set the URL locations having logged on, logged out, taking to user's account page?
Thanks again
Mick
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top