wp_insert_post went into infinity loop problem or return blank page

If you customize WordPress and used wp_insert_post to insert a post into WordPress manually, you might face a problem like i do. The page will go into infinity loop and you ended up on an empty or blank page instead of returning you to your original page/post.  You will start digging into your own code before looking into code. Finally, you found nothing seems to go wrong with your code and start digging into WordPress code. There, you will find wp_insert_post causing you this problem.

wp_insert_post problem

the problem lies with user capability when one use wp_insert_post to give other user the ability to insert post into WordPress. wp_insert_post uses the method current_user_can to check whether the given user has the capability to publish a post. After that i too have no idea what went wrong. However, this only happen when you set your post_status as publish. If you happen to change publish into other status such as draft, you will find that you can successfully insert your WordPress post without the problem of going into an infinity loop. However, this doesn't happen to every WordPress setup. Apparently my TEST environment doesn't seems to get such behavior compared to my LIVE one. Furthermore, if you dig deeper into WordPress wp_insert_post used methods, you will find that none of them are using any expensive loop or redirect function. Therefore, i suspect one of the method in wp_insert_post is performing a checking with user capability and publish post. a lighten me if you manage to find out what's wrong.

wp_insert_post solution

But i want my user to have the capability of a subscribers but is able to publish a post themselves. If you are like me, you may want to try to bypass the checking on publish post. If you look into the code implementation of wp_insert_post, you will find that most of the checking are looking for the keyword publish. Another alternative to publish your post without using the keyword publish is to use alternative keyword, future. The keyword future allows you to publish your post almost instantly similar to publish but it is a bit slower as the schedule will have to take care of publishing the article of yours. That's it, you shouldn't be getting an infinity loop after using future instead of publish! Good luck!

Tutorial: disable _blank attribute from opening new window

Today is an interesting day. I was working on my project and found that i have a hard time looking for a way to disable my target attribute, _blank, which will open a new window and display the item there.  Surprisingly, i found tons of how to create pop out box and many discussion regarding setting up a window.open instruction. But no one care to explain how to stop or disable it! Hence, i decide to write it out myself.

Pop out box

We all know how to enable a pop out box. We can do that either by window.open or using target attribute _blank to pass the work to another window. We can also do that for form submission but bringing out another box is not very professional unless you are showing certain information. Hence, most of us will go with ajax or iframe way of synchronize submission. Nonetheless, pop out box is a necessity in our web environment. While opening a new window box is easy but how about disabling it?

Disable _blank attribute

Disabling a pop out box or anything that will pop out is pretty simple. If you try to recall how you disable those anchor link, you might have an idea how you are going to disable all other types of link. Most pop out box is being initialize by a click. Hence, the event that we are interested with is onclick event handler. However, different people will have different ways of disabling an anchor link such as

<a href="JavaScript: void();">link</a>

or

<a href="#">link</a>

But we are interested in

<a href="JavaScript: return false;">link</a>

In order to disable pop out, it is the same as how we used to disable link. Hence, if you have a link such as this,

<a href="http://somewhere.com" target="_blank">link</a>

it will bring you to somewhere.com on a new pop out box. And if you want to prevent that, you will do this.

<a href="http://somewhere.com" target="_blank" onclick='return false;'>link</a>

That's it! To prevent window.open, we just remove that sentence! haha..

WordPress filter hook pre_comment_approved

I was really busy this whole month which makes me neglected Hungred Dot Com a lot. But i will still try to keep up with it as soon as possible. This article will definitely help ANYONE who uses wordpress filter hook 'pre_comment_approved'. I search Google for a while but couldn't get any help so i decided to investigate instead. The documentation of this hook is a bit screwed up. I'm sure they will edit it in the future. Nonetheless, for people who are having problem using this (you should be). Here is a solution i can provide.

Problem with pre_comment_approved

The problem i am having with pre_comment_approved is that i am UNABLE to retrieve the comment id that should be attached with this filter hook. Instead, the parameter for this action hook is just a simple status to tell you what status is being applied to a particular comment. The purpose of having this filter hook is to enable anyone to change the status into something else instead of approve eg, 'spam'. But some of us will want to do something else with it and we would like to know which comment has been approved. On the documentation, it said that there is a global variable $comment_ID which you can use in the function that you used to hook pre_comment_approved. Unfortunately, it doesn't exist. Try using the global variable $comment. You will get null (i have no idea why too). So how do you identify comment are we dealing with?

Solution to find comment ID in pre_comment_approved

After cracking my brain and stress for a while. I stare at the core code of WordPress and found some global variable to test (that is why i know $comment_ID and $comment was empty/null). There is a global variable $comment_id instead of $comment_ID in the core implementation of WordPress. But both of them gives you nothing. Hence, if you like to find the whole detail, your/my best bet will be the global variable $commentdata. Here is a simple way of getting your pre_comment_approved filter work.

add_filter('pre_comment_approved', array($this, 'alertUser'),);
public function alertUser($status){
	global $wpdb, $commentdata;
	echo $commentdata['comment_author'];
	echo $commentdata['comment_author_email'];
	echo $commentdata['comment_content'];
	echo $commentdata['comment_post_ID'];
	// etc..
}

With this, you should save some time figuring how and why the heck it is not working ($comment_ID, this is misleading).

List Of All Jobs in a select box

Today i was working on a registration and i needed a list of all job available for my user to choose. What will most of us do when this happen? Search Google! After that i left with despite because i fail to find such resource. The next terrifying thing most developer look at is the list of job available on Wikipedia (it just keep on going, damnit). Imagining compiling the whole few hundred list of job just to get them into a select box. Well, you don't have to imagine because i already did it. Hence, you get the joy while i do the work. lol~

<select class="select" id="selectbox" name="selectbox">
		<option value="Athlete">Athlete</option>
		<option value="Accountant">Accountant</option>
		<option value="Actor">Actor</option>
		<option value="Actress">Actress</option>
		<option value="Administrator">Administrator</option>
		<option value="Aerospace Engineer">Aerospace Engineer</option>
		<option value="Air Traffic Controller">Air Traffic Controller</option>
		<option value="Ambassador">Ambassador</option>
		<option value="Anesthetist">Anesthetist</option>
		<option value="Anchorman">Anchorman</option>
		<option value="Animator">Animator</option>
		<option value="Animal trainer">Animal trainer</option>
		<option value="Archaeologist">Archaeologist</option>
		<option value="Architect">Architect</option>
		<option value="Artist">Artist</option>
		<option value="Astronaut">Astronaut</option>
		<option value="Astronomer">Astronomer</option>
		<option value="Athletic trainer">Athletic trainer</option>
		<option value="Attorney">Attorney</option>
		<option value="Author">Author</option>
		<option value="Army">Army</option>
		<option value="Brain Surgeon">Brain Surgeon</option>
		<option value="Baker">Baker</option>
		<option value="Bank teller">Bank teller</option>
		<option value="Banker">Banker</option>
		<option value="Barber">Barber</option>
		<option value="Barista">Barista</option>
		<option value="Barrister">Barrister</option>
		<option value="Bartender">Bartender</option>
		<option value="Babysitter">Babysitter</option>
		<option value="Beauty queen">Beauty queen</option>
		<option value="Beauty therapist">Beauty therapist</option>
		<option value="Beekeeper">Beekeeper</option>
		<option value="Blacksmith">Blacksmith</option>
		<option value="Boilermaker">Boilermaker</option>
		<option value="Bookkeeper">Bookkeeper</option>
		<option value="Bookseller">Bookseller</option>
		<option value="Brewer">Brewer</option>
		<option value="Butcher">Butcher</option>
		<option value="Butler">Butler</option>
		<option value="Builder">Builder</option>
		<option value="Cab driver">Cab driver</option>
		<option value="Calligrapher">Calligrapher</option>
		<option value="Cameraman">Cameraman</option>
		<option value="Car designer">Car designer</option>
		<option value="Cardiologist">Cardiologist</option>
		<option value="Carpenter">Carpenter</option>
		<option value="Cartoonist">Cartoonist</option>
		<option value="Cartographer">Cartographer</option>
		<option value="Cashier">Cashier</option>
		<option value="Cellist">Cellist</option>
		<option value="Chess player">Chess player</option>
		<option value="CIO (Chief Information Officer)">CIO (Chief Information Officer)</option>
		<option value="CEO (Chief Executive Officer)">CEO (Chief Executive Officer)</option>
		<option value="CTO (Chief Technology Officer)">CTO (Chief Technology Officer)</option>
		<option value="CFO (Chief Financial Officer)">CFO (Chief Financial Officer)</option>
		<option value="Chauffeur">Chauffeur</option>
		<option value="Cheesemaker">Cheesemaker</option>
		<option value="Cook)">Cook)</option>
		<option value="Chemist">Chemist</option>
		<option value="Chief of police">Chief of police</option>
		<option value="Chimney sweep">Chimney sweep</option>
		<option value="Civil servant">Civil servant</option>
		<option value="Civil engineer">Civil engineer</option>
		<option value="Clarinetist">Clarinetist</option>
		<option value="Cleaner">Cleaner</option>
		<option value="Clerk">Clerk</option>
		<option value="Clockmaker">Clockmaker</option>
		<option value="Coach">Coach</option>
		<option value="Coachman">Coachman</option>
		<option value="Coast guard">Coast guard</option>
		<option value="Cobbler">Cobbler</option>
		<option value="Columnist">Columnist</option>
		<option value="Comedian">Comedian</option>
		<option value="Company Secretary">Company Secretary</option>
		<option value="Compasssmith">Compasssmith</option>
		<option value="Composer">Composer</option>
		<option value="Computer programmer">Computer programmer</option>
		<option value="Conductor (music)">Conductor (music)</option>
		<option value="Construction engineer">Construction engineer</option>
		<option value="Construction worker">Construction worker</option>
		<option value="Consul">Consul</option>
		<option value="Consultant">Consultant</option>
		<option value="Contractor, general">Contractor, general</option>
		<option value="Coroner">Coroner</option>
		<option value="Corrector">Corrector</option>
		<option value="Cosmonaut">Cosmonaut</option>
		<option value="Costume Designer">Costume Designer</option>
		<option value="Courier">Courier</option>
		<option value="Cryptographer">Cryptographer</option>
		<option value="Currier">Currier</option>
		<option value="Customs officer">Customs officer</option>
		<option value="Dancer">Dancer</option>
		<option value="Dentist">Dentist</option>
		<option value="Deputy (law enforcement)">Deputy (law enforcement)</option>
		<option value="Dermatologist">Dermatologist</option>
		<option value="Designer/Developer">Designer/Developer</option>
		<option value="Detective">Detective</option>
		<option value="Dictator">Dictator</option>
		<option value="Disc jockey">Disc jockey</option>
		<option value="Diver">Diver</option>
		<option value="Doctor">Doctor</option>
		<option value="Dog walker">Dog walker</option>
		<option value="Doorman">Doorman</option>
		<option value="Dressmaker">Dressmaker</option>
		<option value="Ecologist">Ecologist</option>
		<option value="Economist">Economist</option>
		<option value="Editor">Editor</option>
		<option value="Electrical engineer">Electrical engineer</option>
		<option value="Electrician">Electrician</option>
		<option value="Elevator mechanic">Elevator mechanic</option>
		<option value="Engineer">Engineer</option>
		<option value="Engraver">Engraver</option>
		<option value="Entrepreneur">Entrepreneur</option>
		<option value="Environmental scientist">Environmental scientist</option>
		<option value="Executive manager">Executive manager</option>
		<option value="Exterminator">Exterminator</option>
		<option value="Falconer">Falconer</option>
		<option value="Farmer">Farmer</option>
		<option value="Farrier">Farrier</option>
		<option value="Fashion designer">Fashion designer</option>
		<option value="FBI Agent">FBI Agent</option>
		<option value="Film director">Film director</option>
		<option value="Film producer">Film producer</option>
		<option value="Financial adviser">Financial adviser</option>
		<option value="Fire marshal">Fire marshal</option>
		<option value="Fire Safety Officer">Fire Safety Officer</option>
		<option value="Firefighter">Firefighter</option>
		<option value="First Mate">First Mate</option>
		<option value="Fishmonger">Fishmonger</option>
		<option value="Fisherman">Fisherman</option>
		<option value="Fitter">Fitter</option>
		<option value="Flavorist">Flavorist</option>
		<option value="Fletcher">Fletcher</option>
		<option value="Flight attendant">Flight attendant</option>
		<option value="Flight instructor">Flight instructor</option>
		<option value="Florist">Florist</option>
		<option value="Flutist">Flutist</option>
		<option value="Food critic">Food critic</option>
		<option value="Footballer">Footballer</option>
		<option value="Forester">Forester</option>
		<option value="Fortune teller">Fortune teller</option>
		<option value="Funeral Director">Funeral Director</option>
		<option value="Gamekeeper">Gamekeeper</option>
		<option value="Game designer">Game designer</option>
		<option value="Gardener">Gardener</option>
		<option value="Gemcutter">Gemcutter</option>
		<option value="Genealogist">Genealogist</option>
		<option value="General">General</option>
		<option value="Geologist">Geologist</option>
		<option value="Goldsmith">Goldsmith</option>
		<option value="Government agent">Government agent</option>
		<option value="Governor">Governor</option>
		<option value="Graphic Designer">Graphic Designer</option>
		<option value="Gravedigger">Gravedigger</option>
		<option value="Greengrocer">Greengrocer</option>
		<option value="Grocer">Grocer</option>
		<option value="Guide">Guide</option>
		<option value="Guitarist">Guitarist</option>
		<option value="Gunsmith">Gunsmith</option>
		<option value="Harpist">Harpist</option>
		<option value="Handyman">Handyman</option>
		<option value="Hairdresser">Hairdresser</option>
		<option value="Harbourmaster">Harbourmaster</option>
		<option value="Harper">Harper</option>
		<option value="Hatter">Hatter</option>
		<option value="Historian">Historian</option>
		<option value="Homeopath">Homeopath</option>
		<option value="Hotel manager">Hotel manager</option>
		<option value="Housekeeper">Housekeeper</option>
		<option value="Hairstylist">Hairstylist</option>
		<option value="Human Resource Manager">Human Resource Manager</option>
		<option value="Human Resource Assistant">Human Resource Assistant</option>
		<option value="Illuminator">Illuminator</option>
		<option value="Illusionist">Illusionist</option>
		<option value="Illustrator">Illustrator</option>
		<option value="Importer">Importer</option>
		<option value="Industrial engineer">Industrial engineer</option>
		<option value="Industrialist">Industrialist</option>
		<option value="Information Technologist">Information Technologist</option>
		<option value="Information Designer">Information Designer</option>
		<option value="Inker">Inker</option>
		<option value="Innkeeper">Innkeeper</option>
		<option value="Instructor">Instructor</option>
		<option value="Interior designer">Interior designer</option>
		<option value="Interpreter">Interpreter</option>
		<option value="Interrogator">Interrogator</option>
		<option value="Inventor">Inventor</option>
		<option value="disambiguation needed">disambiguation needed</option>
		<option value="Investment banker">Investment banker</option>
		<option value="Investment broker">Investment broker</option>
		<option value="Ironmonger">Ironmonger</option>
		<option value="Ironmaster">Ironmaster</option>
		<option value="Ironworker">Ironworker</option>
		<option value="Jailer">Jailer</option>
		<option value="Janitor">Janitor</option>
		<option value="Jeweller">Jeweller</option>
		<option value="Journalist">Journalist</option>
		<option value="Jurist">Jurist</option>
		<option value="Judge">Judge</option>
		<option value="Jockey">Jockey</option>
		<option value="Joggler">Joggler</option>
		<option value="Karate master">Karate master</option>
		<option value="Kinesiologist">Kinesiologist</option>
		<option value="Laborer">Laborer</option>
		<option value="Landlady)">Landlady)</option>
		<option value="Lavendar)">Lavendar)</option>
		<option value="Law enforcement agent">Law enforcement agent</option>
		<option value="Lawyer">Lawyer</option>
		<option value="Leadworker">Leadworker</option>
		<option value="Leatherer">Leatherer</option>
		<option value="Leather worker">Leather worker</option>
		<option value="Lecturer">Lecturer</option>
		<option value="Level designer (also Mapper)">Level designer (also Mapper)</option>
		<option value="Librarianship">Librarianship</option>
		<option value="Librettist">Librettist</option>
		<option value="Lifeguard">Lifeguard</option>
		<option value="Lighthouse keeper">Lighthouse keeper</option>
		<option value="Lighting technician">Lighting technician</option>
		<option value="Lineman">Lineman</option>
		<option value="Linguist">Linguist</option>
		<option value="Loan officer">Loan officer</option>
		<option value="Lobbyist">Lobbyist</option>
		<option value="Locksmith">Locksmith</option>
		<option value="Lumberjack">Lumberjack</option>
		<option value="Lyricist">Lyricist</option>
		<option value="Magistrate">Magistrate</option>
		<option value="Magnate">Magnate</option>
		<option value="Maid">Maid</option>
		<option value="Mailman or Mail carrier">Mailman or Mail carrier</option>
		<option value="Make-up artist">Make-up artist</option>
		<option value="Management consultant">Management consultant</option>
		<option value="Manager">Manager</option>
		<option value="Manicurist">Manicurist</option>
		<option value="Manufacturer">Manufacturer</option>
		<option value="Marine">Marine</option>
		<option value="Marine biologist">Marine biologist</option>
		<option value="Market gardener">Market gardener</option>
		<option value="Martial artist">Martial artist</option>
		<option value="Mason">Mason</option>
		<option value="Master of business administration">Master of business administration</option>
		<option value="MC)">MC)</option>
		<option value="masseur)">masseur)</option>
		<option value="Matador">Matador</option>
		<option value="Mathematician">Mathematician</option>
		<option value="Mechanic">Mechanic</option>
		<option value="Mechanical Engineer">Mechanical Engineer</option>
		<option value="Mechanician">Mechanician</option>
		<option value="Mediator">Mediator</option>
		<option value="Medic">Medic</option>
		<option value="Medical biller">Medical biller</option>
		<option value="Medical Transcriptionist">Medical Transcriptionist</option>
		<option value="Mesmerist">Mesmerist</option>
		<option value="Messenger">Messenger</option>
		<option value="Mid-wife">Mid-wife</option>
		<option value="Milkmaid)">Milkmaid)</option>
		<option value="Miller">Miller</option>
		<option value="Miner">Miner</option>
		<option value="Missionary">Missionary</option>
		<option value="Model">Model</option>
		<option value="Modeller">Modeller</option>
		<option value="Moneychanger">Moneychanger</option>
		<option value="Moneylender">Moneylender</option>
		<option value="Monk">Monk</option>
		<option value="Mortgage broker">Mortgage broker</option>
		<option value="Mountaineer">Mountaineer</option>
		<option value="Muralist">Muralist</option>
		<option value="Musician">Musician</option>
		<option value="Navigator">Navigator</option>
		<option value="N??gociant">N??gociant</option>
		<option value="Negotiator">Negotiator</option>
		<option value="Netmaker">Netmaker</option>
		<option value="Neurologist">Neurologist</option>
		<option value="Newscaster">Newscaster</option>
		<option value="Night auditor">Night auditor</option>
		<option value="Nightwatchmen">Nightwatchmen</option>
		<option value="Notary">Notary</option>
		<option value="Novelist">Novelist</option>
		<option value="Numerologist">Numerologist</option>
		<option value="Numismatist">Numismatist</option>
		<option value="Nun">Nun</option>
		<option value="Nursemaid">Nursemaid</option>
		<option value="Nurse">Nurse</option>
		<option value="Nutritionist">Nutritionist</option>
		<option value="Oboist">Oboist</option>
		<option value="Obstetrician">Obstetrician</option>
		<option value="Occupational therapist">Occupational therapist</option>
		<option value="Odontologist">Odontologist</option>
		<option value="Oncologist">Oncologist</option>
		<option value="Ontologist">Ontologist</option>
		<option value="Operator">Operator</option>
		<option value="Ophthalmologist">Ophthalmologist</option>
		<option value="Optometrist)">Optometrist)</option>
		<option value="Oracle">Oracle</option>
		<option value="Ordinary Seaman">Ordinary Seaman</option>
		<option value="disambiguation needed">disambiguation needed</option>
		<option value="Orthodontist">Orthodontist</option>
		<option value="Ornithologist">Ornithologist</option>
		<option value="Ostler">Ostler</option>
		<option value="Otorhinolaryngologist">Otorhinolaryngologist</option>
		<option value="Optometrist">Optometrist</option>
		<option value="Ocularist">Ocularist</option>
		<option value="Opthamologist">Opthamologist</option>
		<option value="Painter">Painter</option>
		<option value="Paleontologist">Paleontologist</option>
		<option value="Paralegal">Paralegal</option>
		<option value="Paramedic">Paramedic</option>
		<option value="Park ranger">Park ranger</option>
		<option value="Parole Officer">Parole Officer</option>
		<option value="Pastor">Pastor</option>
		<option value="Patent attorney">Patent attorney</option>
		<option value="Patent examiner">Patent examiner</option>
		<option value="Pathologist">Pathologist</option>
		<option value="Pawnbroker">Pawnbroker</option>
		<option value="Peddler">Peddler</option>
		<option value="Pediatrician">Pediatrician</option>
		<option value="Pedologist (soil)">Pedologist (soil)</option>
		<option value="Percussionist">Percussionist</option>
		<option value="Perfumer">Perfumer</option>
		<option value="Personal Trainer">Personal Trainer</option>
		<option value="Pharmacist">Pharmacist</option>
		<option value="Philanthropist">Philanthropist</option>
		<option value="Philologist">Philologist</option>
		<option value="Philosopher">Philosopher</option>
		<option value="Photographer">Photographer</option>
		<option value="Photo Specialist">Photo Specialist</option>
		<option value="Physical Therapist">Physical Therapist</option>
		<option value="Physician">Physician</option>
		<option value="Physician Assistant">Physician Assistant</option>
		<option value="Physicist">Physicist</option>
		<option value="Physiognomist">Physiognomist</option>
		<option value="Physiotherapist">Physiotherapist</option>
		<option value="Pianist">Pianist</option>
		<option value="Piano tuner">Piano tuner</option>
		<option value="Pilot (shipping)">Pilot (shipping)</option>
		<option value="Pilot (aviation)">Pilot (aviation)</option>
		<option value="Pirate">Pirate</option>
		<option value="Plumber">Plumber</option>
		<option value="Podiatrist">Podiatrist</option>
		<option value="Poet">Poet</option>
		<option value="Police inspector">Police inspector</option>
		<option value="Politician">Politician</option>
		<option value="disambiguation needed">disambiguation needed</option>
		<option value="Presenter">Presenter</option>
		<option value="President">President</option>
		<option value="Press officer">Press officer</option>
		<option value="Priest">Priest</option>
		<option value="Princess">Princess</option>
		<option value="Principal">Principal</option>
		<option value="Printer">Printer</option>
		<option value="Private detective">Private detective</option>
		<option value="Probation Officer">Probation Officer</option>
		<option value="Proctologist">Proctologist</option>
		<option value="Product designer">Product designer</option>
		<option value="Professor">Professor</option>
		<option value="Professional dominant">Professional dominant</option>
		<option value="Programmer">Programmer</option>
		<option value="Project Manager">Project Manager</option>
		<option value="Proofreader">Proofreader</option>
		<option value="Psychiatrist">Psychiatrist</option>
		<option value="Psychodramatist">Psychodramatist</option>
		<option value="Psychologist">Psychologist</option>
		<option value="Public Relations Officer">Public Relations Officer</option>
		<option value="Public speaker">Public speaker</option>
		<option value="Publisher">Publisher</option>
		<option value="Porn star">Porn star</option>
		<option value="Queen consort">Queen consort</option>
		<option value="Queen regnant">Queen regnant</option>
		<option value="Quilter">Quilter</option>
		<option value="Radiologist">Radiologist</option>
		<option value="Radiographer">Radiographer</option>
		<option value="Real estate broker">Real estate broker</option>
		<option value="Real estate investor">Real estate investor</option>
		<option value="Real estate developer">Real estate developer</option>
		<option value="Receptionist">Receptionist</option>
		<option value="Record Producer">Record Producer</option>
		<option value="Referee">Referee</option>
		<option value="Refuse collector">Refuse collector</option>
		<option value="Registrar">Registrar</option>
		<option value="Reporter">Reporter</option>
		<option value="Researcher">Researcher</option>
		<option value="Respiratory Therapist">Respiratory Therapist</option>
		<option value="Restaurateur">Restaurateur</option>
		<option value="Retailer">Retailer</option>
		<option value="Rubbish Collector">Rubbish Collector</option>
		<option value="Sailmaker">Sailmaker</option>
		<option value="Sailor">Sailor</option>
		<option value="Salesmen">Salesmen</option>
		<option value="Sanitation worker">Sanitation worker</option>
		<option value="Saucier">Saucier</option>
		<option value="Saxophonist">Saxophonist</option>
		<option value="disambiguation needed">disambiguation needed</option>
		<option value="Scientist">Scientist</option>
		<option value="School superintendent">School superintendent</option>
		<option value="Scout">Scout</option>
		<option value="Screenwriter">Screenwriter</option>
		<option value="Scrivener)">Scrivener)</option>
		<option value="Seamstress">Seamstress</option>
		<option value="Second Mate">Second Mate</option>
		<option value="Secret service agent">Secret service agent</option>
		<option value="Secretary general">Secretary general</option>
		<option value="Security guard">Security guard</option>
		<option value="Senator">Senator</option>
		<option value="SEO (search engine optimizer)">SEO (search engine optimizer)</option>
		<option value="Sexton">Sexton</option>
		<option value="Sheepshearer">Sheepshearer</option>
		<option value="Sheriff">Sheriff</option>
		<option value="Sheriff officer">Sheriff officer</option>
		<option value="Shoemaker">Shoemaker</option>
		<option value="Shop assistant">Shop assistant</option>
		<option value="Singer">Singer</option>
		<option value="Skydiver">Skydiver</option>
		<option value="Sleeper">Sleeper</option>
		<option value="Sleuth">Sleuth</option>
		<option value="Social worker">Social worker</option>
		<option value="Socialite">Socialite</option>
		<option value="Software engineer">Software engineer</option>
		<option value="Soil scientist">Soil scientist</option>
		<option value="Soldier">Soldier</option>
		<option value="Solicitor">Solicitor</option>
		<option value="Sommelier">Sommelier</option>
		<option value="Sonographer">Sonographer</option>
		<option value="Sound Engineer">Sound Engineer</option>
		<option value="Special agent">Special agent</option>
		<option value="Speech therapist">Speech therapist</option>
		<option value="Sportsman">Sportsman</option>
		<option value="Spy">Spy</option>
		<option value="Statistician">Statistician</option>
		<option value="Street artist">Street artist</option>
		<option value="Street musician">Street musician</option>
		<option value="Stevedore">Stevedore</option>
		<option value="Street sweeper">Street sweeper</option>
		<option value="Street vendor">Street vendor</option>
		<option value="Structural engineers">Structural engineers</option>
		<option value="Stunt double">Stunt double</option>
		<option value="Stunt performer">Stunt performer</option>
		<option value="Surgeon">Surgeon</option>
		<option value="Supervisor">Supervisor</option>
		<option value="Surveyor">Surveyor</option>
		<option value="Swimmer">Swimmer</option>
		<option value="Switchboard operator">Switchboard operator</option>
		<option value="System administrator">System administrator</option>
		<option value="Systems analyst">Systems analyst</option>
		<option value="Student">Student</option>
		<option value="Tailor">Tailor</option>
		<option value="Tanner">Tanner</option>
		<option value="Tapester)">Tapester)</option>
		<option value="Tax Collector">Tax Collector</option>
		<option value="Tax Lawyer">Tax Lawyer</option>
		<option value="Taxidermist">Taxidermist</option>
		<option value="Taxicab driver">Taxicab driver</option>
		<option value="Taxonomist">Taxonomist</option>
		<option value="Tea lady">Tea lady</option>
		<option value="Teacher">Teacher</option>
		<option value="Technician">Technician</option>
		<option value="Technologist">Technologist</option>
		<option value="Technical Writer">Technical Writer</option>
		<option value="Telegraph operator)">Telegraph operator)</option>
		<option value="Telephone operator">Telephone operator</option>
		<option value="Tennis player">Tennis player</option>
		<option value="Test developer">Test developer</option>
		<option value="Test pilot">Test pilot</option>
		<option value="Torchwood Officer">Torchwood Officer</option>
		<option value="Thatcher">Thatcher</option>
		<option value="Theatre director">Theatre director</option>
		<option value="Therapist">Therapist</option>
		<option value="Thimbler">Thimbler</option>
		<option value="Tiler">Tiler</option>
		<option value="Toolmaker">Toolmaker</option>
		<option value="Trademark attorney">Trademark attorney</option>
		<option value="Trader">Trader</option>
		<option value="Tradesman">Tradesman</option>
		<option value="Trainer (business)">Trainer (business)</option>
		<option value="Transit planner">Transit planner</option>
		<option value="Translator">Translator</option>
		<option value="Treasurer">Treasurer</option>
		<option value="Truck Driver">Truck Driver</option>
		<option value="Turner">Turner</option>
		<option value="Tutor">Tutor</option>
		<option value="Tyler">Tyler</option>
		<option value="Typist">Typist</option>
		<option value="Undertaker">Undertaker</option>
		<option value="Ufologist">Ufologist</option>
		<option value="Undercover agent">Undercover agent</option>
		<option value="Underwriter">Underwriter</option>
		<option value="Upholsterer">Upholsterer</option>
		<option value="Urologist">Urologist</option>
		<option value="Usher">Usher</option>
		<option value="Underwear model">Underwear model</option>
		<option value="Valet">Valet</option>
		<option value="Verger">Verger</option>
		<option value="Veterinarian">Veterinarian</option>
		<option value="Vibraphonist">Vibraphonist</option>
		<option value="Vicar">Vicar</option>
		<option value="Video editor">Video editor</option>
		<option value="Video game developer">Video game developer</option>
		<option value="Vintner">Vintner</option>
		<option value="Violinist">Violinist</option>
		<option value="Violist">Violist</option>
		<option value="Voice Actor">Voice Actor</option>
		<option value="Waitress)">Waitress)</option>
		<option value="disambiguation needed">disambiguation needed</option>
		<option value="Watchmaker">Watchmaker</option>
		<option value="Weaponsmith">Weaponsmith</option>
		<option value="Weatherman">Weatherman</option>
		<option value="Weaver">Weaver</option>
		<option value="Web designer">Web designer</option>
		<option value="Web developer">Web developer</option>
		<option value="Wedding Planner">Wedding Planner</option>
		<option value="Welder">Welder</option>
		<option value="Wet nurse">Wet nurse</option>
		<option value="Woodcarver">Woodcarver</option>
		<option value="Wood cutter">Wood cutter</option>
		<option value="Wrangler">Wrangler</option>
		<option value="Winemaker">Winemaker</option>
		<option value="Writer">Writer</option>
		<option value="Xylophonist">Xylophonist</option>
		<option value="Yodeler">Yodeler</option>
		<option value="Zookeeper">Zookeeper</option>
		<option value="Zoologist">Zoologist</option>
	</select>

Enjoy 🙂

Update:

I notice the above is pretty hard to find which has been previously selected by the user. Hence, i place them into an array and put it up here hopefully someone will find it useful for a list of all jobs in a php array 🙂

<select class="select" id="user_job" name="user_job">
		<option value=""> - Job - </option>
		<?php
			$loop = array('Athlete',		'Accountant',		'Actor',		'Actress',		'Administrator',		'Aerospace Engineer',		'Air Traffic Controller',		'Ambassador',		'Anesthetist',		'Anchorman',		'Animator',		'Animal trainer',		'Archaeologist',		'Architect',		'Artist',		'Astronaut',		'Astronomer',		'Athletic trainer',		'Attorney',		'Author',		'Army',		'Brain Surgeon',		'Baker',		'Bank teller',		'Banker',		'Barber',		'Barista',		'Barrister',		'Bartender',		'Babysitter',		'Beauty queen',		'Beauty therapist',		'Beekeeper',		'Blacksmith',		'Boilermaker',		'Bookkeeper',		'Bookseller',		'Brewer',		'Butcher',		'Butler',		'Builder',		'Cab driver',		'Calligrapher',		'Cameraman',		'Car designer',		'Cardiologist',		'Carpenter',		'Cartoonist',		'Cartographer',		'Cashier',		'Cellist',		'Chess player',		'CIO (Chief Information Officer)',		'CEO (Chief Executive Officer)',		'CTO (Chief Technology Officer)',		'CFO (Chief Financial Officer)',		'Chauffeur',		'Cheesemaker',		'Cook)',		'Chemist',		'Chief of police',		'Chimney sweep',		'Civil servant',		'Civil engineer',		'Clarinetist',		'Cleaner',		'Clerk',		'Clockmaker',		'Coach',		'Coachman',		'Coast guard',		'Cobbler',		'Columnist',		'Comedian',		'Company Secretary',		'Compasssmith',		'Composer',		'Computer programmer',		'Conductor (music)',		'Construction engineer',		'Construction worker',		'Consul',		'Consultant',		'Contractor, general',		'Coroner',		'Corrector',		'Cosmonaut',		'Costume Designer',		'Courier',		'Cryptographer',		'Currier',		'Customs officer',		'Dancer',		'Dentist',		'Deputy (law enforcement)',		'Dermatologist',		'Designer/Developer',		'Detective',		'Dictator',		'Disc jockey',		'Diver',		'Doctor',		'Dog walker',		'Doorman',		'Dressmaker',		'Ecologist',		'Economist',		'Editor',		'Electrical engineer',		'Electrician',		'Elevator mechanic',		'Engineer',		'Engraver',		'Entrepreneur',		'Environmental scientist',		'Executive manager',		'Exterminator',		'Falconer',		'Farmer',		'Farrier',		'Fashion designer',		'FBI Agent',		'Film director',		'Film producer',		'Financial adviser',		'Fire marshal',		'Fire Safety Officer',		'Firefighter',		'First Mate',		'Fishmonger',		'Fisherman',		'Fitter',		'Flavorist',		'Fletcher',		'Flight attendant',		'Flight instructor',		'Florist',		'Flutist',		'Food critic',		'Footballer',		'Forester',		'Fortune teller',		'Funeral Director',		'Gamekeeper',		'Game designer',		'Gardener',		'Gemcutter',		'Genealogist',		'General',		'Geologist',		'Goldsmith',		'Government agent',		'Governor',		'Graphic Designer',		'Gravedigger',		'Greengrocer',		'Grocer',		'Guide',		'Guitarist',		'Gunsmith',		'Harpist',		'Handyman',		'Hairdresser',		'Harbourmaster',		'Harper',		'Hatter',		'Historian',		'Homeopath',		'Hotel manager',		'Housekeeper',		'Hairstylist',		'Human Resource Manager',		'Human Resource Assistant',		'Illuminator',		'Illusionist',		'Illustrator',		'Importer',		'Industrial engineer',		'Industrialist',		'Information Technologist',		'Information Designer',		'Inker',		'Innkeeper',		'Instructor',		'Interior designer',		'Interpreter',		'Interrogator',		'Inventor',		'disambiguation needed',		'Investment banker',		'Investment broker',		'Ironmonger',		'Ironmaster',		'Ironworker',		'Jailer',		'Janitor',		'Jeweller',		'Journalist',		'Jurist',		'Judge',		'Jockey',		'Joggler',		'Karate master',		'Kinesiologist',		'Laborer',		'Landlady)',		'Lavendar)',		'Law enforcement agent',		'Lawyer',		'Leadworker',		'Leatherer',		'Leather worker',		'Lecturer',		'Level designer (also Mapper)',		'Librarianship',		'Librettist',		'Lifeguard',		'Lighthouse keeper',		'Lighting technician',		'Lineman',		'Linguist',		'Loan officer',		'Lobbyist',		'Locksmith',		'Lumberjack',		'Lyricist',		'Magistrate',		'Magnate',		'Maid',		'Mailman or Mail carrier',		'Make-up artist',		'Management consultant',		'Manager',		'Manicurist',		'Manufacturer',		'Marine',		'Marine biologist',		'Market gardener',		'Martial artist',		'Mason',		'Master of business administration',		'MC)',		'masseur)',		'Matador',		'Mathematician',		'Mechanic',		'Mechanical Engineer',		'Mechanician',		'Mediator',		'Medic',		'Medical biller',		'Medical Transcriptionist',		'Mesmerist',		'Messenger',		'Mid-wife',		'Milkmaid)',		'Miller',		'Miner',		'Missionary',		'Model',		'Modeller',		'Moneychanger',		'Moneylender',		'Monk',		'Mortgage broker',		'Mountaineer',		'Muralist',		'Musician',		'Navigator',		'N??gociant',		'Negotiator',		'Netmaker',		'Neurologist',		'Newscaster',		'Night auditor',		'Nightwatchmen',		'Notary',		'Novelist',		'Numerologist',		'Numismatist',		'Nun',		'Nursemaid',		'Nurse',		'Nutritionist',		'Oboist',		'Obstetrician',		'Occupational therapist',		'Odontologist',		'Oncologist',		'Ontologist',		'Operator',		'Ophthalmologist',		'Optometrist)',		'Oracle',		'Ordinary Seaman',		'disambiguation needed',		'Orthodontist',		'Ornithologist',		'Ostler',		'Otorhinolaryngologist',		'Optometrist',		'Ocularist',		'Opthamologist',		'Painter',		'Paleontologist',		'Paralegal',		'Paramedic',		'Park ranger',		'Parole Officer',		'Pastor',		'Patent attorney',		'Patent examiner',		'Pathologist',		'Pawnbroker',		'Peddler',		'Pediatrician',		'Pedologist (soil)',		'Percussionist',		'Perfumer',		'Personal Trainer',		'Pharmacist',		'Philanthropist',		'Philologist',		'Philosopher',		'Photographer',		'Photo Specialist',		'Physical Therapist',		'Physician',		'Physician Assistant',		'Physicist',		'Physiognomist',		'Physiotherapist',		'Pianist',		'Piano tuner',		'Pilot (shipping)',		'Pilot (aviation)',		'Pirate',		'Plumber',		'Podiatrist',		'Poet',		'Police inspector',		'Politician',		'disambiguation needed',		'Presenter',		'President',		'Press officer',		'Priest',		'Princess',		'Principal',		'Printer',		'Private detective',		'Probation Officer',		'Proctologist',		'Product designer',		'Professor',		'Professional dominant',		'Programmer',		'Project Manager',		'Proofreader',		'Psychiatrist',		'Psychodramatist',		'Psychologist',		'Public Relations Officer',		'Public speaker',		'Publisher',		'Porn star',		'Queen consort',		'Queen regnant',		'Quilter',		'Radiologist',		'Radiographer',		'Real estate broker',		'Real estate investor',		'Real estate developer',		'Receptionist',		'Record Producer',		'Referee',		'Refuse collector',		'Registrar',		'Reporter',		'Researcher',		'Respiratory Therapist',		'Restaurateur',		'Retailer',		'Rubbish Collector',		'Sailmaker',		'Sailor',		'Salesmen',		'Sanitation worker',		'Saucier',		'Saxophonist',		'disambiguation needed',		'Scientist',		'School superintendent',		'Scout',		'Screenwriter',		'Scrivener)',		'Seamstress',		'Second Mate',		'Secret service agent',		'Secretary general',		'Security guard',		'Senator',		'SEO (search engine optimizer)',		'Sexton',		'Sheepshearer',		'Sheriff',		'Sheriff officer',		'Shoemaker',		'Shop assistant',		'Singer',		'Skydiver',		'Sleeper',		'Sleuth',		'Social worker',		'Socialite',		'Software engineer',		'Soil scientist',		'Soldier',		'Solicitor',		'Sommelier',		'Sonographer',		'Sound Engineer',		'Special agent',		'Speech therapist',		'Sportsman',		'Spy',		'Statistician',		'Street artist',		'Street musician',		'Stevedore',		'Street sweeper',		'Street vendor',		'Structural engineers',		'Stunt double',		'Stunt performer',		'Surgeon',		'Supervisor',		'Surveyor',		'Swimmer',		'Switchboard operator',		'System administrator',		'Systems analyst',		'Student',		'Tailor',		'Tanner',		'Tapester)',		'Tax Collector',		'Tax Lawyer',		'Taxidermist',		'Taxicab driver',		'Taxonomist',		'Tea lady',		'Teacher',		'Technician',		'Technologist',		'Technical Writer',		'Telegraph operator)',		'Telephone operator',		'Tennis player',		'Test developer',		'Test pilot',		'Torchwood Officer',		'Thatcher',		'Theatre director',		'Therapist',		'Thimbler',		'Tiler',		'Toolmaker',		'Trademark attorney',		'Trader',		'Tradesman',		'Trainer (business)',		'Transit planner',		'Translator',		'Treasurer',		'Truck Driver',		'Turner',		'Tutor',		'Tyler',		'Typist',		'Undertaker',		'Ufologist',		'Undercover agent',		'Underwriter',		'Upholsterer',		'Urologist',		'Usher',		'Underwear model',		'Valet',		'Verger',		'Veterinarian',		'Vibraphonist',		'Vicar',		'Video editor',		'Video game developer',		'Vintner',		'Violinist',		'Violist',		'Voice Actor',		'Waitress)',		'disambiguation needed',		'Watchmaker',		'Weaponsmith',		'Weatherman',		'Weaver',		'Web designer',		'Web developer',		'Wedding Planner',		'Welder',		'Wet nurse',		'Woodcarver',		'Wood cutter',		'Wrangler',		'Winemaker',		'Writer',		'Xylophonist',		'Yodeler',		'Zookeeper',		'Zoologist');
			foreach($loop as $value){
				if($_POST['user_job'] == $value )
				echo '<option value="'.$value.'" selected>'.$value.'</option>';
				else
				echo '<option value="'.$value.'">'.$value.'</option>';
			}
		?>
	</select>

Get Tag With Post ID In WordPress

Today i was writing my plugin and required each post tag to be placed into a variable outside of WordPress loop. I have a look at WordPress function reference api and did some Google and surprisingly i couldn't find it. After a long time of digging on Google, i finally found a clue. Apparently, the method get_the_tags takes in a post id! However, if you look at get_the_tags reference page, it doesn't mention at all. Hence, i decides to write it down here to ease people life in the future.

Get Tag In WordPress

Once you get hold of your Post ID you can easily retrieve the tag associated with the post with the following code.

			$postid = $post->ID;
			get_the_tags($postid);

It will return a list of tags. Hope it helps 🙂