wp_update_user and user_login

September 4, 2012 Leave a comment

The most frustrating part till now, the solution what i got, is writing a query which i didn’t liked. So i was searching more of a native wordpress function. Wen i was using wp_update_user with its arguments & i was adding user_login to update my username. Everything was fine but when i tried updating the user_login it used to be the same the day i created the user. So then after looking all over unfortunately there is only one way to do it and which is :

      $wpdb->query("UPDATE $wpdb->users SET user_login = '[new_user]' WHERE ID = '[user_id]'");

WordPress strictly discourage to update username/user_login.

Categories: Wordpress Development

embed Video in post without shortcode (WordPress)

July 11, 2012 1 comment

WordPress from long time were using shortcode to embed video from youtube, but since 2.9 they dynamically insert a object code on entering the url.


Just you need to paste the link (without square brackets) and it will automatically convert to video. Here are the list of supported site http://codex.wordpress.org/Embeds.


Categories: Wordpress Development

Customize Admin Area for WordPress

May 22, 2012 Leave a comment

Hellow Guys,
Wordpress provides a great power to customize most of the things via wordpress, like curd operations on admin menu’s, customizing admin bar (which will be covered in my coming posts).

So today we would work with one of the awesome functionality by wordpress itself, like removing the unwanted menus from admin area. You might be thinking that we could simply hide it why to use the function, correct that’s also the way but remember always do the right way where ever you can.

We just need to call the following function to remove any menu you want to

remove_menu_page( $menu_slug );

$menu_slug is the file name which is called on clicking of the menu, like for user operation wordpress call’s users.php. So if you pass users.php as a “menu slug” then it will remove the entire “Users” menu from admin area. Now you may be wondering that how will i remove the sub menu from the admin area. Simple, just use the following function with the php file name and the parent file name as specified below.

remove_submenu_page( $menu_slug, $submenu_slug )

So say you need to remove some menu’s for author then you may just use the above function’s on admin init. That will make your life more simpler 🙂 … Also do not forget to check the user rights…  For details you may visit remove menuremove sub menu

Hope this helps.. Stay tuned for more ….

Implementing jsonp for cross domain request

May 19, 2012 Leave a comment

Your would be very happy when it comes to crossdomain with ajax call. I have one of the solution to make a crossdomain successful with jsonp.


The main problem for making a cross domain request is many browser has a security restriction as we cannot make any request other than the current domain.


The solution is jsonp, but you might be thinking how does that work to0?

We all know that javascript can be included with any domain, there is no restriction for that . So we can use the same thing to get our desired output.

I have created a test application in php to give a response to a get request.

$callback_function = $_GET['callback'];</pre>
//some json generated via some logic.
$some_json_string = '{"menu": {
 "id": "file",
 "value": "File",
 "popup": {
 "menuitem": [
 {"value": "New", "onclick": "CreateNewDoc()"},
 {"value": "Open", "onclick": "OpenDoc()"},
 {"value": "Close", "onclick": "CloseDoc()"}

//set header as we need to return the javascript
header('Content-type: application/javascript');

//return with a function which was set as a callback
echo $callback_function.'('.$some_json_string.')';

Also some javascript code in your html/php file which is on other domain.


You can refer to the following screenshot. You can also check the domain from which i am calling. The domains have been changed via host file.
cross domain jsonp request...
I will be implementing jsonp without getJson method. Hope this will save lot of your time ..

Categories: Wordpress Development

WordPress Logout Redirect not working (Solved)

May 17, 2012 4 comments

I know you all be so happy to see the title of the post. Yes there is a solution for adding a redirect after being logout.


I was using

 echo wp_logout_url( home_url() );

It seems so simple. When we look at the url it works properly with a parameter “redirect_to”. But whenever you try to use that it will always go to default wordpress login page. I researched and found out that domain mapping plugin is stopping it from redirecting. I tried fixing it in domain mapping itself but it was a waste of time .


But then wordpress offers amazing power with hooks. Then i found out there is one hook where i could call a function after doing redirect.


This calls the function after deleting the cookie and signing out . So i wrote a function that will check if it has a redirect_to parameter in url then could redirect to destination else will redirect to where it came from. If you don’t want to redirect to HTTP_REFERER then you can always use


function redirect_me(){

//if the user has rights of editor then return don't do anything
 if(current_user_can('editor')) return;

//get the reffer or you may user home_url() if the "request_to" is not set
 $logout_redirect_url = $_SERVER['HTTP_REFERER'];
 if(!empty($_REQUEST['redirect_to'])) wp_safe_redirect($_REQUEST['redirect_to']);
 else wp_redirect($logout_redirect_url);

Hope this solution helps .

Add menu into wordpress page

May 11, 2011 Leave a comment

Hello Folks,

Since many days i was wondering to add a dynamic menus that i could insert via plugin. I wanted to insert login and logout buttons into menu bar without editing the template. Then i found out one hook for the wordpress that i could inject my content into menu.


The above hook will call add_menu which contain 2 parameters.

      function add_menu($items,$args)
            items .= "<li>Another Menu</li>";
            return items;

it will look as following

As you can see another menu is created beside. As css is not applied it looks like that apply css would
look alike.

If there is any problem give a reply.

People You Can Kiss On Internet

May 4, 2011 Leave a comment

Hello Readers,

Now the technology has reached the level where you can send kiss over internet to your loved once . So now you don’t have to wait for the loved once to com and meet you for your precious kiss unless you have some other option at home hehehe .

So from this technology you can simulate French Kiss to a gr8 extent,actually i haven’t tried it but i would love to give a try .. 😀  So i am waiting for it to come it to the market hehehe . Thats y i love technology .

There is a hardware required from both the side to do the kissing simulation over the internet .

Let me know your feedbacks if any 😀

Flat, Shiny Keyboard Is Actually a Touch screen

April 28, 2011 Leave a comment

If you like typing on a touch screen, you’re going to love this thin Minebea Cool Leaf Keyboard.
Touch screen keybord

Strangely enough, even though the keyboard itself is one large touch screen, it doesn’t bring any of the versatility could offer. For instance, imagine substituting a video window for the number pad, or designing your own keyboard layouts for specific tasks, or even displaying tool palettes for Photoshop. Let’s hope Minebea explores that kind of versatility with this keyboard that already possesses multitouch capability.
If you’re touch typist, the inability to feel the keys might be a dealbreaker, but if you’re a germ freak, this flat and shiny keyboard will be a whole lot easier to keep clean. It must be a fingerprint magnet, as evidenced by its shiny nature and included cleaning cloth.
Touch Screen Keybord
To be released first in Japan on May 13, it’s a USB keyboard with 108 keys that only works with Windows thus far. Minebea reps say a Mac version will be available soon, and the Japanese version will be rolling out first, followed by those that contain the correct character set and key layout for English, German, French and Italian.
When you turn the keyboard off, its surface is reflective enough to be used as a mirror, perfect for looking yourself in the face and asking yourself this question: Why did I just spend $245 on this keyboard?
Check the video out.


Adding template page from plugin

April 18, 2011 Leave a comment

Hello readers,

I have found a very simple solutions to assign a template page to specific or all pages . According to my previous tutorial for creating the template page and placing into the wordpress current template.

For creating the template you need to add comment on the top of the page as known from my blog

Template Name: new template

Now what ever you want add the functionality to the page and then add header/footer as on your preference.
Now your template file is ready to run or attach to page. But now no need to copy that php file to the template folder of wordpress.
all you need to do is call the following hook

add_filter( 'page_template', 'catch_plugin_template' );

Now this will be called on every page/post load.

add_filter( 'page_template', 'catch_plugin_template' );
function catch_plugin_template($template)
$template = WP_PLUGIN_DIR . '/yourpluginname/template-file.php';
return $template;

Now the above could will execute on every page and the template would be assigned to all the pages you have created.

Thank You for reading.

Auto save problem for custom variables

April 14, 2011 2 comments

Readers while developing with wordpress i found a problem with the post . I had custom variable into my metabox.

So there is a default hook to be called to save that custom variable into the database.


So by default when u click publish post or update post then ‘function_save_var’ would be called .
So when u update the post and then close the page then this would work perfectly fine but then i din know
auto save would call this hook too .

So when my page would be open for a while all my values would reset and my functionality would fail. So
after a little search i got the solution.

function function_save_var()
       // Function without avoiding auto save.

The above function would fail as it would reset everything .

but then to avoid; you need to add the following code in the start of the function

        return $post_id;

if the post will autosave this would directly return n do not update anything . Thus this is all solved.

%d bloggers like this: