Code to get the Facebook login status on a website

Embed the code to know the login status of a user on a a website

It will tell you whether the user is logged in or not in his facebook account.if user is logged in then it will fetch the user name and profile pic and will display it.

 

<h1>Login, Logout, Name and Profile Picture</h1>
<div id=”account-info”></div>

<script>
function showAccountInfo() {
FB.api(
{
method: ‘fql.query’,
query: ‘SELECT name, pic_square FROM user WHERE uid=’+FB.getUserID()
},
function(response) {
Log.info(‘API Callback’, response);
document.getElementById(‘account-info’).innerHTML = (
‘<img src=”‘ + response[0].pic_square + ‘”> ‘ +
response[0].name +
‘ <button class=”btn” onclick=”FB.logout()”>Logout</button>’
);
}
);
}

 

function showLoginButton() {
document.getElementById(‘account-info’).innerHTML = (
‘<button class=”btn btn-primary” onclick=”FB.login()”>Login</button>’
);
}

 

function onStatus(response) {
Log.info(‘onStatus’, response);
if (response.status === ‘connected’) {
showAccountInfo();
} else {
showLoginButton();
}
}
FB.getLoginStatus(function(response) {
onStatus(response);
FB.Event.subscribe(‘auth.statusChange’, onStatus);
});
</script>

How to add Jquery Datepicker/Calender Plugin in wordpress form

It takes time to add jquery ui calneder plugin to add in WordPress

The reason is the jquery conflict which arise due to many JS libraries in the wordpress theme

To add the calender follow the steps

add the below script

<form>

<input type=”text” name=”jdate” id=”journeydate”>

</form>

<?php
wp_enqueue_script(‘jquery-ui-datepicker’);
wp_enqueue_style(‘jquery-style’, ‘http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/dot-luv/jquery-ui.css’);
?>

in the above css link you can replace “dot-luv” with your jquery ui theme name. (another trick 4 u ;) )
<script type=”text/javascript”>

jQuery(document).ready(function() {
jQuery(‘#journeydate’).datepicker({
dateFormat : ‘dd-mm-yy’
});
});

</script>

Keep Coding !

Zombie Softwares(\m/)

 

How to close bootstrap modal manually

I was working on a project , i have a scenario where i need to close the modal for the save with using Ajax content displaying in the modal box.

I don’t want to refresh the page , since i was using form with modal box. To close the modal use below code.

$(‘#modelid’).modal(‘hide’);

Hope it works for someone.

base_url() not working in Codeigniter

In Codeigniter we user base_url() to refer as site url of the website.

We set its value in config.php file in the config folder.

If base_url() is not working then , it means you have not loaded the helper file.

so you have to add below lines in the autoload.php file

$autoload['helper'] = array(‘url’);

.Hope it works for you :)