Find Jobs
Hire Freelancers

fix a custom wordpress function that I wrote

$30-250 USD

Suljettu
Julkaistu noin 10 vuotta sitten

$30-250 USD

Maksettu toimituksen yhteydessä
I am trying to create a multi criteria post rating function with a simple form and post_meta and user meta. The Goal ------------- when users submits their ratings 2 things should happen: [login to view URL] ratings is stored in the post_meta called 'wpd_rating' like this: array(user id => array( field1 => 5 field2 => 3 field3 => 4 ), another user id => array( field1 => 2 field2 => 5 field3 => 4 ) ) [login to view URL] ratings is stored in the user_meta called 'plgn_rating' like this: array(post id => array( field1 => 5 field2 => 3 field3 => 4 ), another rated post id => array( field1 => 2 field2 => 5 field3 => 4 ) ) The Code (Not working Obviously) ----------------------------------- **In [login to view URL]:** the header part: <?php // top of page if ( isset( $_POST['drw_inventory'] ) && wp_verify_nonce($_POST['drw_inventory'],'update_drw_postmeta') ) { //if nonce check succeeds. global $post; $postid = $post->ID; $data = $_POST['wpd_function_rating']; $data2 = $_POST['wpd_feature_rating']; $data3 = $_POST['wpd_support_rating']; $currentusr = get_current_user_id(); //*******************The post meta field Part**************************** //Get the Existing user ratings of this post $ls_up_votes = get_post_meta($postid, 'wpd_rating'); //if the current user already rated, unset the rating foreach ( $ls_up_votes as $key => $value ) { if ( $key == $currentusr ) { unset( $ls_up_votes[$key] ); } } //Add post meta 'wpd_rating' with this structure: //array(userid => array('wpd_function_rating' => '3','wpd_feature_rating' => '5','wpd_support_rating' => '4',)) $up_vote = array($currentusr => array('wpd_function_rating' => $data,'wpd_feature_rating' => $data2,'wpd_support_rating' => $data3)); //appending new user ratings after one another $ls_up_voted = array_merge($ls_up_votes, $up_vote); update_post_meta($postid,'wpd_rating',$ls_up_voted); //*******************The user field Part**************************** //Get the Current user ratings of this post $user_rated_posts = get_user_meta($currentusr, 'plgn_rating',true); foreach ( $user_rated_posts as $key => $value ) { if ( $key == $postid ) { unset( $user_rated_posts[$key] ); } } //add a user field 'plgn_rating' with this structure //(postid => array('wpd_function_rating' => '3','wpd_feature_rating' => '5','wpd_support_rating' => '4',)) $usr_vote = array($postid => array('wpd_function_rating' => $data,'wpd_feature_rating' => $data2,'wpd_support_rating' => $data3)); //appending new user ratings after one another $ls_up_voted = array_merge($user_rated_posts, $usr_vote); update_user_meta($currentusr,'plgn_rating',$ls_up_voted); } ?> The Form: <form method="post" action=""> <?php wp_nonce_field('update_drw_postmeta','drw_inventory'); ?> <label>This is label</label> <input type='text' name='wpd_function_rating' value='' /> <input type='text' name='wpd_feature_rating' value='' /> <input type='text' name='wpd_support_rating' value='' /> <input type='submit' value='save' /> </form> Issues with the current code 1. The array is not saving as I structured. I am pretty sure I am using the array_merge wrong. or the calling the get_post_meta wrong. 2. The code is not checking for the existing user rating and replacing the old ratings with the new one. p.s: you can add this to any [login to view URL] file and check for the post_meta database to check.
Projektin tunnus (ID): 5401777

Tietoa projektista

13 ehdotukset
Etäprojekti
Aktiivinen 10 vuotta sitten

Haluatko ansaita rahaa?

Freelancerin tarjouskilpailun edut

Aseta budjettisi ja aikataulu
Saa maksu työstäsi
Kuvaile ehdotustasi
Rekisteröinti ja töihin tarjoaminen on ilmaista
13 freelancerit tarjoavat keskimäärin $170 USD tätä projektia
Käyttäjän avatar
Hi, I have read your project description and made some test on it, I can fix those function so it works like how you wanted. Thank you
$77 USD 2 päivässä
5,0 (20 arvostelua)
4,5
4,5
Käyttäjän avatar
Hello, We can create the fix a custom wordpress function that I wrote based on your requirements and timeline. I primarily work with small businesses, professional services and individuals. My goal is to provide quality web solution at a reasonable price. Please let me know your availability and we can discuss the details over Skype or Phone. We have local office in US as well. Regards, Ash
$185 USD 15 päivässä
5,0 (3 arvostelua)
4,1
4,1
Käyttäjän avatar
Hello, We have vast Experience on Website Developing as we are in the market from last 3+ years. We have Sufficient and Well trained Employee Team including Website Developers, Web Designers, SEO Team. We have read your all requirement and would like to have some more words on it. As security purpose on this website we can not see your Website URL, so also we have to discuss on it. We can complete your task within Timeframe. All Portfolios will be provided on request. Waiting for your Favorable Response. Thanks
$155 USD 3 päivässä
5,0 (5 arvostelua)
2,6
2,6
Käyttäjän avatar
Hi there Got your code ready, interesting problem (allthough there are easier ways to fix it). The solution was to pull out the arrays from wpd_rating before the post_meta array_merge. Add me to the project, and I'll send you the code. Thanks, Alex
$155 USD 1 päivässä
5,0 (2 arvostelua)
2,4
2,4
Käyttäjän avatar
A proposal has not yet been provided
$155 USD 3 päivässä
0,0 (0 arvostelua)
0,0
0,0

Tietoja asiakkaasta

Maan BANGLADESH lippu
Dhaka, Bangladesh
5,0
16
Maksutapa vahvistettu
Liittynyt elok. 6, 2009

Asiakkaan vahvistus

Kiitos! Olemme lähettäneet sinulle sähköpostitse linkin, jolla voit lunastaa ilmaisen krediittisi.
Jotain meni pieleen lähetettäessä sähköpostiasi. Yritä uudelleen.
Rekisteröitynyttä käyttäjää Ilmoitettua työtä yhteensä
Freelancer ® is a registered Trademark of Freelancer Technology Pty Limited (ACN 142 189 759)
Copyright © 2024 Freelancer Technology Pty Limited (ACN 142 189 759)
Ladataan esikatselua
Lupa myönnetty Geolocation.
Kirjautumisistuntosi on vanhentunut ja sinut on kirjattu ulos. Kirjaudu uudelleen sisään.