Create a dropdown list displaying users meta data
Create a dropdown list displaying users meta data
Create a dropdown list displaying users meta data
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
Try this code: function postsCount($meta_value) { $args = array( ‘numberposts’ => -1, ‘post_type’ => ‘custom_post_type’, // set you custom post type ‘meta_key’ => ‘project_select’, ‘meta_value’ => $meta_value, ); $my_posts = get_posts( $args ); $postsCount = count($my_posts); return $postsCount; } if ( is_user_logged_in() ) { echo postsCount(‘Draft’); echo postsCount(‘Completed’); } or if you want to get … Read more
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
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
I figured it out myself so I will post the answer here, please note that the original answer can also be found on StackOverflow. If the mods feel like this should be deleted from here and only remain, please go ahead. I thought it might be useful on both places. First the correct code, then … Read more
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
Not sure why you would try this with taxonomy. I would suggest making a meta_key “country” with the values. Then you can query it like in the documentation: $user_query = new WP_User_Query( array( ‘meta_key’ => ‘country’, ‘meta_value’ => ‘Israel’ ) ); Not sure why your taxonomy-query doesnt work, looks fine also, i use it like … Read more
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
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