Show custom meta_value in Newsticker random
-
Hello,
I am not good in coding but I really need something on my wordpress website. Till now I could find all my info on the forums and google and I succeeded for 95% to build my website.
At this moment I run a petition script ‘LH sigining’ This script builds a list of people who subscribed the petition. I needed an extra text area in that form and I managed to get that text area in the form and store the value in the database.
To reach this I use the following filter/function:
function your_form_handler($content, $atts, $post){ if ($post->ID == “154643”){ $content .= ‘<p> <textarea name=”opmerkingen” id=”opmerkingen” rows=”10″ required=”required” placeholder=”a placeholder”></textarea> </p>’; } return $content; } add_filter( ‘lh_signing_intermediate_logged_out_form_filter’, “your_form_handler”, 10, 3); function your_post_handler($user_id){ if ($_POST[‘opmerkingen’]){ add_user_meta( $user_id, ‘opmerkingen’, sanitize_text_field($_POST[‘opmerkingen’])); } } add_filter( ‘lh_signing_http_post_filter’, “your_post_handler”, 10, 1 );
So If people write the text area with their comment it is stored in my database. I have tested it and the textarea ‘opmerkingen’ is showing up:
SELECT * FROM 'wp_usermeta' WHERE 'meta_key' LIKE 'opmerkingen'
In the mysql database it is showing one record now. Displaying ‘umeta_id’, ‘user0_id’, ‘meta_key’ (opmerkingen) and ‘meta_value’ (the value given by that user.What I need/want is a way to show the custom meta_values of Meta_key: opmerkingen on a page in my website one by one.
I Need it to show random and only if the meta_value exists. I want it to show without user id, user name or whatever extra field. I only want to show the textarea input given by a user.
The text is about why they did sign the petition. So , on the petition page I want to show something like:
” At this moment allready [number / count I allready have] persons have signed this petition because: [HERE I WANT TO DISPLAY THE RANDOM META_VALUE OF THE META_KEY ‘OPMERKINGEN’]”
The counter is working allready. I cannot find out how to get the data from my database and show it one by one randomly refreshing with page change or on a timed intervall.
I tried to rebuild a lot of $wpdb arguments but without any luck. My skills are to less to solve this. I really hope somebody can give me an advice how to make / write this piece of code so I can finish my project.
It is possible I am thinking wrong of my approach but I do think I should get the value of text area ‘ opmerkingen’ out of my database.. But how?
Sorry for any bad english
Warm regards
Jap
- The topic ‘Show custom meta_value in Newsticker random’ is closed to new replies.