auth_redirect help
-
Hi,
I am working on making an auth_redirect around a button on my site, but I simply can’t figure out where to insert the auth_redirect for it to work.
The function has to be so that when the user clicks on the button, it will first check to see if the user is logged in, and if not, will take the user to a customized login page, then taking the user back to the page he/she was on before.
At the moment, with the code I’ve written, the button will take the user to a login page (and the user has to reload the page manually after registering), then to the front page, but not back to the previous page.
function custom_listify_single_job_listing_actions_after() { global $post; if ( is_user_logged_in() ) { $url = get_post_meta( $post->ID, 'my_meta_key', true ); ?> <a href="<?php echo esc_url( $url );?>" class="button" target="_blank">BUTTON </a> <?php } else { echo '<a href="http://mysite.com/login-to-see-the-link/" class="button">BUTTON</a>'; }; } add_filter( 'listify_single_job_listing_actions_after', 'custom_listify_single_job_listing_actions_after' );
I really hope you guys can help, as I’m struggling with this annoying error.
Thanks!
- The topic ‘auth_redirect help’ is closed to new replies.