Home›Forums›Feature Requests›Volunteer Sign-Up Sheets – Feature Requests›Adding login log out to page instead of message
- This topic has 2 replies, 2 voices, and was last updated 9 years, 9 months ago by Gary White.
-
AuthorPosts
-
-
March 16, 2015 at 7:53 AM #2900Gary WhiteParticipant
I have one other question. If the signup is set to logged in users only a message (You must be logged in to a valid account to view and sign up for volunteer opportunities.) is displayed. What file and where in the file could this be changed to include a link to log in or out? This is the code I would like to add
<div class=”login-links<?php if ($topnav_pos == ‘right’) echo ‘ right’; ?><?php if ($switcher_pos == ‘top’ && $minicart_pos == ‘top’ && $topnav_pos != ‘none’) echo ‘ pos2′ ?>”><?php if ( is_user_logged_in() ) : ?>
<span class=”avatar”><?php echo get_avatar( get_current_user_id(), $size = ’28’ ); ?></span>
<?php if ( in_array( ‘woocommerce/woocommerce.php’, apply_filters( ‘active_plugins’, get_option( ‘active_plugins’ ) ) ) ) : ?>
” class=”nav-top-link”><?php _e(‘Logout’, ‘venedor’); ?>
<?php else : ?>
” class=”nav-top-link”><?php _e(‘Log Out’); ?>
<?php endif; ?>
<?php else: ?>
<?php if ( in_array( ‘woocommerce/woocommerce.php’, apply_filters( ‘active_plugins’, get_option( ‘active_plugins’ ) ) ) ) : ?>
” class=”nav-top-link”><?php _e(‘Login’, ‘woocommerce’); ?>
<?php echo _e(‘or’, ‘venedor’) ?>
” class=”nav-top-link”><?php _e(‘Register’, ‘woocommerce’); ?>
<?php else : ?>
” class=”nav-top-link”><?php _e(‘Login’, ‘venedor’); ?>
<?php echo _e(‘or’, ‘venedor’) ?>
” class=”nav-top-link”><?php _e(‘Register’, ‘venedor’); ?>
<?php endif; ?>
<?php endif; ?>
</div>
-
March 16, 2015 at 8:33 AM #2901Stephen SherrardKeymaster
I would usually recommend that you don’t directly modify the plugin file, as any changes you make will get wiped out if you update the plugin in the future.
Login/Logout would normally be handled the same way you already do for your WordPress site. There are plenty of sidebar widgets you can use for login/logout without going to the regular WordPress login page if you want.
However, if you want to modify the code, you can find that message in the:
class-pta_sus_public.php
file on line 195.But, if you just wanted to add some login links conditionally without actually modifying the plugin code, note that there is a built-in action hook on line 181 that fires before the shortcode for my plugin is processed.
You could add a script similar to what you just posted into your theme’s functions.php file, and hook into my ‘pta_sus_before_process_shortcode’ action hook, where you can check if the user is logged in or not on your own, and display your own message and login/logout links. Then you can use the option in the settings for my plugin to disable the login notices so that they will only see your notices and not mine.
If you aren’t familiar with how the action hooks work, do a quick internet search and you’ll find plenty of info about them, but basically you add some code into your functions.php file like this:
add_action('pta_sus_before_process_shortcode', 'my_login_function'); function my_login_function { // do some stuff here - check if they are logged in, echo/return your form/links, etc. }
-
March 16, 2015 at 8:42 AM #2902Gary WhiteParticipant
Thank you very much for your response. You have been very helpful!
-
-
AuthorPosts
- You must be logged in to reply to this topic.