How to show value from ACF plugin field in e-mail?

It was the thing in the order of functions, and the check : if(is_user_logged_in()){ $current_user = wp_get_current_user(); } else { $user_id = get_post_field( ‘post_author’, $post_id ); $current_user = get_userdata($user_id); }

how to iterate through xml data?

Looks like you would need to loop the XML object results, eg: $comments = array(); foreach ($object->survey as $index => $survey) { if (is_string($survey->comments)) {$comments[$index] = $survey->comments;} } print_r($comments); // to see comments

send meta box input data without publish button

You can get the post id like this var post_id = $(‘input[name=”post_ID”]’).val(); See this full working code. BTW its only save the value to the meta in the ajax it won’t save it on the publish button you need to add another hook with another function. you can’t use the same function that you used … Read more

Reading CSV values and showing them in PHP

Not too hard really… $csvdata = file_get_contents($filepath); $lines = explode(“\n”, $csvdata); // split data by new lines foreach ($lines as $i => $line) { $values = explode(‘,’, $line); // split lines by commas // set values removing them as we ago $linevalues[$i][‘name’] = trim($values[0]); unset($values[0]); $linevalues[$i][‘country’] = trim($values[1]); unset($values[1]); $linevalues[$i][‘color’] = trim($values[2]); unset($values[2]); // assign … Read more

Load Meta box value into div AJAX [duplicate]

Add data attribute data-post-id for the post id. Eg. HTML: <ul> <li><button class=”play_next” data-meta-key=”url-1″ data-post-id=”<?php the_ID(); ?>”>Video 1</button></li> … </ul> Missing data attributes in js. $( this ).data( ‘metaKey’ ); should be $( this ).data( ‘meta-key’ ); and $( this ).data( ‘post_id’ ); should be $( this ).data( ‘post-id’ ); E.g. Jquery: jQuery( document ).ready( … Read more

PHP Use Declared array Variable inside already Declared Array

This is more a generic PHP question than anything to do with WordPress, but I’d suggest setting the value in the constructor: class test { public $basicCols; public $optList = array( ‘one’ => ‘One’, ‘two’ => ‘Two’ ); function __construct() { $this->basicCols = array( array( ‘title’ => ‘KEY’, ‘field’ => ‘slug’, ‘options’ => $this->optList ), … Read more