Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- function frontend_login_script( $user, $user_id ) {
- if( $user ) {
- $login_message = apply_filters( 'appp_login_success', sprintf( __('Welcome back %s!', 'apppresser'), $user->display_name), $user->ID );
- $username = $user->user_login;
- $avatar_url = get_avatar_url( $user->ID );
- $login_redirect = appp_get_login_redirect();
- ?>
- <script type="text/javascript">
- var login_data = {
- message: '<?php echo $login_message; ?>', // welcome message
- username: '<?php echo $username; ?>', // name used in greeting
- avatar: '<?php echo $avatar_url; ?>', // URL to the avatar
- login_redirect: '<?php echo $login_redirect; ?>' // optional login redirect
- }
- window.apppresser.sendLoginMsg( true, login_data );
- </script><?php
- }
- }
- function appp_get_login_redirect() {
- if( has_filter( 'appp_login_redirect' ) ) {
- $redirect_to = apply_filters( 'appp_login_redirect', '' );
- $post_id = url_to_postid( $redirect_to );
- $redirect = array(
- 'url' => $redirect_to,
- 'title' => ($post_id) ? get_the_title( $post_id ) : '',
- );
- } else {
- $redirect = '';
- }
- return $redirect;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement