Is it possible in WordPress

Use the project name in the meta key field & the amount donated as the meta value, and I would suggest using update_user_meta rather than add_user_meta because reasons. Something like this: $project=”donated_to_” . $project; update_user_meta( $user_id, $project, $amount ); Apply some sort of logic before setting those variables – you know, in case the user … Read more

How to work with AJAX and WordPress?

You’re not using wordpress default ajax mechanism. To do that: jQuery.ajax({ type: “POST”, url: “/wp-admin/admin-ajax.php”, // Send request to admin-ajax.php data: newcontact, // Can be anything. As per your need action: ‘myaction’, // Required to send otherwise WordPress AJAX won’t authorize your request. success: function(data) { jQuery(“.follow-user”).html(data); } }); AJAX Request Handler add_action( ‘wp_ajax_myaction’, ‘so_wp_ajax_function’ … Read more

update_usermeta don’t work

You should enable WP_DEBUG mode, so that the white screen of death will give you a more useful error message. The white screen could be caused by a typo, but it looks ok to me. Does your host have simplexml_load_string()? If you don’t have the simple XML library, that could be why returning $setlink works, … Read more

Automatically Populate Post Taxonomy Data Based on Post Author Meta Data?

Figured it out for anyone who wants to know: function update_school( $post_id ) { $post_author_id = get_post_field( ‘post_author’, $post_id ); // get the post author ID $school_name = get_the_author_meta( ‘school2’, $post_author_id ); // from the post author ID, get the author meta $term = term_exists( $school_name, ‘school’); wp_set_post_terms( $post_id, $term, ‘school’ ); } // run … Read more

If logged in user meta is

No, not correct – get_user_meta() returns meta data based on the $user_id parameter you provide. You can combine it with get_current_user_id() to check if an user is logged in and than – if so – get the post meta. E.g. like this: $curr_user_id = get_current_user_id(); // the value is 0 if the user isn’t logged-in … Read more

Update vs Insert logic but the last key is always inserted?

Ok here’s my altered function but this one doesn’t work at all but maybe you can see wher i go wrong function insertUserShoppingMetaData($params) { global $wpdb; $shopping_meta_table=”wp_shopping_metavalues”; $wp_user_id = $params[‘wp_user_id’]; $checkKeyValues = $wpdb->get_results(“SELECT meta_shopping_key FROM $shopping_meta_table WHERE wp_user_id = ‘$wp_user_id'”); //print_r($checkKeyValues); foreach ($params as $key => $val) { foreach($checkKeyValues as $check){ //UPDATE OR INSERT if … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)