Create a new plugin for Wordpress (called "mood01"). The plugin will do four main things
1) Upon installing the plugin, it will create a custom table in MySQL (detail below)
2) Create a shortcode to generate HTML for a form (detail below)
3) Create a hook to process the data from the form defined in #2 (see detail below)
4) Create a shortcode to render HTML for an unordered list of 7 records from the custom table (detail below)
#1: CREATING CUSTOM TABLE
The custom table should be created ( [url removed, login to view] ) for storing records created by the [collect_mood_form] plugin. The PHP snippet used for creating this table should be:
$table_name = $wpdb->prefix . "mood_sample";
$sql = "CREATE TABLE $table_name (
id mediumint(9) NOT NULL AUTO_INCREMENT ,
wp_user_id mediumint(9) NOT NULL,
sample_time datetime DEFAULT NOW() NOT NULL,
mood_code int NOT NULL,
annotation varchar(255) DEFAULT '' NOT NULL,
PRIMARY KEY pk_id (id),
INDEX ix_user_day (wp_user_id,serial_day_num ASC)
#2: SHORTCODE FOR HTML FORM
Create a shortcode called [mood_log_form] which renders the following HTML:
Enter wordpress user id:
#3: PROCESS FORM
When data is POSTed to the /process_mood_sample by the above form, the plugin should insert a record into the mood_sample table created in step 1. It should then redirect to the currently logged in user's profile page.
#4: SHORTCODE FOR LATEST RECORDS
Create a shortcode called [latest_mood_list] which runs a SELECT query on the mood_sample table and finds the most recent 7 records for the currently logged in user's id ( mood_sample.wp_user_id == get_current_user_id() ). It outputs the records so that they appear as HTML like shown below, with the entries in descending date order (newest sample_time records appearing at the top).
sample_time: 2013-02-09 mood_code:7
sample_time: 2013-02-08 mood_code:7
sample_time: 2013-02-07 mood_code:7
sample_time: 2013-01-29 mood_code:7
sample_time: 2013-01-25 mood_code:7
sample_time: 2013-01-19 mood_code:7
sample_time: 2013-01-04 mood_code:7
Some of the HTML above appears distorted. I am attaching a plain text file that repeats the description above.
5 freelanceria on tarjonnut keskimäärin %project_bid_stats_avg_sub_26% %project_currencyDetails_sign_sub_27% tähän työhön
Dear Sir, Greetings! We are Reform Consulting with 5 years of experience under our belt. We are really interested to work on your project. Please see PM. Thank you. Regards, RCPL.