Forum Replies Created

Viewing 7 replies - 1 through 7 (of 7 total)
  • Thread Starter blue92877

    (@blue92877)

    ..actually, from that ticket, this works pretty well.

    $fields = new WP_Job_Manager_Writepanels();
      $job_fields = $fields->job_listing_fields();
      var_dump($job_fields);

    I’ll keep an eye out there, but this is getting me where I need to be, and we can close this out.

    Thanks!

    Thread Starter blue92877

    (@blue92877)

    One of my problems I’ve found is a misunderstanding of how wp_insert_post works. I mistakenly expected wp_insert_post to create empty values for the meta data, just like when hitting the ‘save draft’ button – which is why I could get the fields after doing it manually, but not programmatically.

    I came across this issue, and it’s the exact issue I’m up against at the moment:

    https://github.com/Automattic/WP-Job-Manager/issues/492

    I’ll try the writepanels solution you suggested, but ultimately definitely looking forward to being able to get a list of $keys through a helper function.

    In the meantime, I’m playing around with this based on the link you posted:

    add_action('wp', 'process');
    function process(){
    $meta = apply_filters('job_manager_job_listing_data_fields', $fields);
    var_dump($meta);
    }

    I can get a list keys in the dump, but it’s not a complete list. It’s only the fields added or modified by Fields Editor, but not anything added by Jobify or other WPJM extension plugins.

    I’m still playing with it. Let me know if you have a suggestion! Thanks!

    Thread Starter blue92877

    (@blue92877)

    A quick update.

    If I actually go into the edit screen of a job listing and click the “Save Draft” button, the above code works fine for any items I manually went in and did that for.

    Any idea what is happening that only allows that to work after doing that? I’m more perplexed now than before.

    Thanks!

    Blue

    Thread Starter blue92877

    (@blue92877)

    Consider the following code, which programmatically saves a post to the job_listing post type in WordPress

    public function save_to_wordpress(array $page_elements) {
            $post_id = $this->get_post_id_by_title($page_elements['title']);
    
            if($post_id === false) {
                $post_id = wp_insert_post(
                        array(
                            'comment_status' => 'closed',
                            'ping_status' => 'closed',
                            'post_author' => get_user_by('email', '[email protected]'),
                            'post_title' => $page_elements['title'],
                            'post_status' => 'draft',
                            'post_type' => 'job_listing',
                            'post_content' => $page_elements['description']
                        )
                );
            } else {
               // update job_listing meta data here
    
                print "Post with ID $post_id already exists.<br />";
                $listing = get_post_custom($post_id);
    
                var_dump($listing);
            }
        }

    Inside of the else statement I want to check the value of the job_listing’s custom fields and modify them as needed if the post already exists.

    Originally, I had this code in a plugin, but kept having the same issue. So, I moved into into a child theme page template thinking the same thing – that meta data for the post somehow wasn’t loaded. But that didn’t work either. I can’t check the value of the field if the field isn’t available yet.

    Perhaps an alternative question to this post should have been “How can I update WPJM fields programmatically?”

    Recently I installed the $fields editor and added several new fields to the form. Ultimately what I’m trying to do is programmatically loop through these and update data where needed based on the new form elements. But, to be clear, in my dev environment, the only thing I have enabled is WPJM, so that rules out a conflict there. (But please let me know if you think there could be a conflict with 3rd party plugins or themes. I’ll be using Jobify).

    Thanks!

    Thread Starter blue92877

    (@blue92877)

    Sorry about this post. Another developer had uploaded some code that overrode the ‘supports’ array without me knowing it. Issue resolved. Thanks!

    Thread Starter blue92877

    (@blue92877)

    It did work. Was just a bit hesitant to make a generic change like that since I didn’t know what else I may affect. So far that works fine. Thanks again!

    Thread Starter blue92877

    (@blue92877)

    Sorry, I could have been a bit more clear.

    In your POT file you have the following:

    Showing all %s

    The word “Jobs” isn’t there. I changed to Now getting %s listings and it shows:

    “Now getting Jobs Listings”

    Looks like around line 189 of class-wp-job-manager-ajax.php the word Jobs is being included in a way that it can’t be accessed? Or do I need to translate two or more strings in the POT file?

    I saw where you had __(‘Job’) and __(‘Jobs’) for singular and plural, but I’d hate to make such a global change and have that show up everywhere just for one string.

    Perhaps it’s a feature request to add the word “Jobs” to the translatable string so it can be easily modified for that area only?

    https://gastonia.com if you need to see the site for any reason.

    Thanks!

Viewing 7 replies - 1 through 7 (of 7 total)