Hi everyone! I'm a wordpress / php newbie and need some help:
I'm using the Ajax Login on my WP project. It works great but I have a simple (and very general) php / ajax question. There is this part of the code:
$user_signon = wp_signon( $info, false );
if ( is_wp_error($user_signon) ){
echo json_encode(array('loggedin'=>false, 'message'=>__('NO SUCCESS')));
} else {
echo json_encode(array('loggedin'=>true, 'message'=>__('SUCCESS')));
}
I'd like to include a link in the array something like:
NO SUCCESS <a class="lost" href="<?php echo wp_lostpassword_url(); ?>"><i class="retinaicon-remove"></i> FORGOT YOUR PW?</a>
I'm sorry, I really don't know how to include a link (and an icon) in the array. Can anybody help? Here is the complete Code:
function ajax_login_init(){
wp_register_script('ajax-login-script', get_template_directory_uri() . '/ajax-login-script.js', array('jquery') );
wp_enqueue_script('ajax-login-script');
wp_localize_script( 'ajax-login-script', 'ajax_login_object', array(
'ajaxurl' => admin_url( 'admin-ajax.php' ),
'redirecturl' => home_url(),
'loadingmessage' => __('VERIFYING...'),
));
// Enable the user with no privileges to run ajax_login() in AJAX
add_action( 'wp_ajax_nopriv_ajaxlogin', 'ajax_login' );
}
// Execute the action only if the user isn't logged in
if (!is_user_logged_in()) {
add_action('init', 'ajax_login_init');
}
function ajax_login(){
// First check the nonce, if it fails the function will break
check_ajax_referer( 'ajax-login-nonce', 'security' );
// Nonce is checked, get the POST data and sign user on
$info = array();
$info['user_login'] = $_POST['username'];
$info['user_password'] = $_POST['password'];
$info['remember'] = true;
$user_signon = wp_signon( $info, false );
if ( is_wp_error($user_signon) ){
echo json_encode(array('loggedin'=>false, 'message'=>__('NO SUCCESS')));
} else {
echo json_encode(array('loggedin'=>true, 'message'=>__('SUCCESS')));
}
die();
}