Support » Plugin: Matador Jobs Lite » No author for job post

  • Resolved je3dev

    (@je3dev)


    Hi,

    I was just wondering if there was a way that an author could be set for the job posts when they are created?
    I’m trying to use an auto poster plugin which can see the posts but as they have no author, won’t post them due to the way it works. I did try a little hack to add my user id to the post as it’s created but it broke the job import… so decided not to touch it anymore.

    Thank you

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author Jeremy Scott

    (@jeremyescott)

    Hello again,

    You need to do one to two things. First, you need to enable author support for the job post type:

    
    add_filter( 'matador_post_type_supports_jobs', 'je3dev_add_author_support_to_job', 10, 1); 
    function je3dev_add_author_support_to_job( $supports ) {
      $supports[] = 'author';
      return $supports;
    }
    

    At this point, if I recall correctly, the author will be assigned to the default author, like the Administrator. So to determine the ownership of the job, if it matters, do this:

    
    add_filter( 'matador_import_job_save_args', 'je3dev_job_author', 10, 3 );
    je3dev_job_author( $args, $job, $wpid ) {
      // If there is an ID, we are updating and not creating a job
      if ( ! $wpid ) {
        $args['post_author'] = 1; // Use the ID of the author
      }
      return $args;
    }
    

    This should do what you want. Let me know.

    As a funny aside, we have this joke inside our team here at Matador that “everyone uses Bullhorn and WordPress differently.” I can’t tell you how much effort was put into actually not supporting authors initially. In fact, early in Matador (before it was even called Matador) I struggled to figure out how to do it! I chuckle that I’m helping restore something that so many of our pre-release users hated!

    Thanks for the question!

    je3dev

    (@je3dev)

    Thanks for the speedy reply.

    I have added the code to my must-use plugin but I assume the author will only be added to new posts? This is fine just I ran the sync and the posts seemed to have no author still. My client will add a new job tomorrow so I will check then.

    That is funny and I know what you mean, you never know how a user is ultimately going to use or abuse your code and in how many different ways.

    Thanks again.

    Plugin Author Jeremy Scott

    (@jeremyescott)

    If you want to get author added to existing posts, replace:

    
    if ( ! $wpid ) {
      $args['post_author'] = 1; // Use the ID of the author
    }
    

    with just

    
    $args['post_author'] = 1; // Use the ID of the author
    

    This will reset the author on each sync, so if authorship is important and something changed after sync, you might want to make this one-time edit, run the code, then restore to the original.

    je3dev

    (@je3dev)

    Thanks for that it all works perfectly.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘No author for job post’ is closed to new replies.