• Resolved imaginemonkey

    (@imaginemonkey)


    Basically, what I’m trying to do is this:

    https://wordpress.org/support/topic/copy-jobs-in-the-frontend?replies=2

    It’s just.. that seems like a lot of custom work in PHP. I’m really surprised no one has done anything like this yet. There’s a plugin author who integrated Buddypress and WP Job manager, but all it does is show the dashboard pages as Buddypress profile tabs. It doesn’t display a users job listings on their profile – so it’s a bit pointless.

    I can create a unique profile for a user and add any type of fields I want with Ultimate Users – but would there be a way to insert a shortcode on a members profile and have it display their WP Job manager job listings? (like how it displays in the dashboard)?

    One thing I love about WP Job manager is the features, but it’s sort of lacking in integrating with other member plugins. The buddypress addon plugin that you show in your addons only displays a users dashboard as tabs on their buddypress profile. It doesn’t output a list of their jobs on the profile itself – and the plugin dev told me that WP Job manager doesn’t save any user meta for jobs which is why he couldn’t get it to actually display user jobs.

    https://wordpress.org/plugins/wp-job-manager/

Viewing 13 replies - 1 through 13 (of 13 total)
  • Plugin Author Mike Jolley (a11n)

    (@mikejolley)

    Jobs should not be user meta – they are a thing in themselves. A custom post type. Posted jobs are associated with a user ID in WordPress though, if not posted by a guest.

    The link you posted is completely unrelated to ultimate member.

    What you need to do is create an author template in your theme. https://codex.wordpress.org/Author_Templates

    Then it takes just one get_posts query to retrieve the authors listings.

    Thread Starter imaginemonkey

    (@imaginemonkey)

    Hey,

    Thanks for the feedback.

    So, after messing around last night, and using the UM API to reference profile ID’s, I was able to add some code to my functions PHP file which displays a users recent job listings on their profile page via a shortcode placed on the profile form.

    Referencing the author ID didn’t work because UM works by inserting its core profile shortcode on a page (similar to how you display jobs on a pre-made page with a shortcode). So, when I tried to reference the specific user on the profile being viewed, it would show jobs being called for the author of the page itself (who created it) instead of the UM profile ID.

    View post on imgur.com

    function userjobs_shortcode( $atts ) {
    
      // Attributes
      extract( shortcode_atts(
        array(
          'userid' => um_profile_id(),
        ), $atts )
      );
    
      // Code
    global $post;
    $args = array( 'author' =>  $userid, 'post_type' => 'job_listing', 'posts_per_page' => 10, 'order'=> 'ASC', 'orderby' => 'date' );
    $postslist = get_posts( $args );
    foreach ( $postslist as $post ) :
      setup_postdata( $post ); ?>
        <div>
        <?php the_date(); ?>
        <br />
        <?php the_shortlink(__(get_the_title())); ?>
        <?php the_excerpt(); ?>
      </div>
    <?php
    endforeach;
    wp_reset_postdata();
    }
    add_shortcode( 'userjobs', 'userjobs_shortcode' );
    Plugin Author Mike Jolley (a11n)

    (@mikejolley)

    Yep – that looks correct. Nice work.

    Thread Starter imaginemonkey

    (@imaginemonkey)

    Thank you!

    What would be the function to call if I wanted to display the jobs image, the job type, and if it’s still open or filled? Similar to the information displayed in the [jobs] shortcode.

    Do you have documentation where I could find these?

    Plugin Author Mike Jolley (a11n)

    (@mikejolley)

    Thread Starter imaginemonkey

    (@imaginemonkey)

    Awesome, awesome.

    Looking at the code above – could you help me understand how I would call the template? Would I copy the while or just the function? And would I place it after the “foreach” in my code?

    <?php while ( $jobs->have_posts() ) : $jobs->the_post(); ?>
    					<?php get_job_manager_template_part( 'content', 'job_listing' ); ?>
    				<?php endwhile; ?>
    Thread Starter imaginemonkey

    (@imaginemonkey)

    Ah, I got it:

    foreach ( $postslist as $post ) :
      setup_postdata( $post ); ?>
        <?php get_job_manager_template_part( 'content', 'job_listing' ); ?>
    <?php
    endforeach;

    Thanks!

    Thread Starter imaginemonkey

    (@imaginemonkey)

    Here’s the full code for reference. In UM I had to change the box modal css from “content-box” to “border-box’ to get the data aligned properly.

    Just insert the shortcode [userjobs] on your user role form as a “shortcode” field. And then paste the following code in your functions. This will show the latest jobs from employers on their profile:

    function userjobs_shortcode( $atts ) {
    
      // Attributes
      extract( shortcode_atts(
        array(
          'userid' => um_profile_id(),
        ), $atts )
      );
    
      // Code
    global $post;
    $args = array( 'author' =>  $userid, 'post_type' => 'job_listing', 'posts_per_page' => 10, 'order'=> 'ASC', 'orderby' => 'date' );
         echo '<h2>Latest Job Openings</h2>';
    $postslist = get_posts( $args );
    foreach ( $postslist as $post ) :
      setup_postdata( $post ); ?>
        <?php get_job_manager_template_part( 'content', 'job_listing' ); ?>
    <?php
    endforeach;
    wp_reset_postdata();
    }
    add_shortcode( 'userjobs', 'userjobs_shortcode' );

    Credit for the base code (before modification) goes to these users (and Jolley for directing the OP):

    https://premium.wpmudev.org/forums/topic/get-custom-posts-type-posts-of-certain-user-and-display-them-on-his-user-profile

    Thread Starter imaginemonkey

    (@imaginemonkey)

    Hey Mike,

    I’ve got one more question. Since we are using UM profiles as the “company” profile instead of the company directory WPJM addon – how can I show the UM Profile’s avatar in the listing thumb?

    I’ve removed “company details” from the job submission form – and I notice now that there is no job thumbnail because there is no “company” profile field any more.

    Hello ImagineMonkey,
    I tried your custom function and it work perfectly.Very nice work 🙂 But it placed the code at the beginning of the userprofile.
    However i placed my shortcode at the fourth row ( i have 4 different row.)

    How can we choose the output of the job list. TO choose where to place it?

    Thanks in advance.

    Thread Starter imaginemonkey

    (@imaginemonkey)

    Hey Shimu666,

    No problem. I also ran into the same issue, so what I did was I made custom profile tabs and inserted the shortcode for WP Job Manager pages.

    // Add Job Dash Which Only Shows For Employer While Viewing Their Own Profile Page //
    
    add_filter('um_profile_tabs', 'add_custom_profile_tab1', 7 );
    function add_custom_profile_tab1( $jobtab ) {
    
    if ( um_is_myprofile() && ( um_user('role') == 'employer') ) {
    
      $jobtab['dashboard'] = array(
       'name' => 'Manage Jobs',
       'icon' => 'um-faicon-archive',
       'custom' => true,
      );
    
     }
    
     return $jobtab;
    
    }
    add_action('um_profile_content_dashboard_default', 'um_profile_content_dashboard_default');
    function um_profile_content_dashboard_default( $args ) {
    
        echo do_shortcode('[job_dashboard]');
    
    }
    
    // Add Subscription Tab Which Only Shows For Employer While Viewing Their Own Profile Page If WooCommerce Subscriptions Is Installed //
    
    add_filter('um_profile_tabs', 'add_custom_profile_tab2', 8 );
    function add_custom_profile_tab2( $subscriptiontab ) {
    
    if ( um_is_myprofile() && ( um_user('role') == 'employer') ) {
    
      $subscriptiontab['subscription'] = array(
        'name' => 'Subscription',
        'icon' => 'um-faicon-shopping-cart',
        'custom' => true,
        );
    
        }
    
        return $subscriptiontab;
    
    }
    add_action('um_profile_content_subscription_default', 'um_profile_content_subscription_default');
    function um_profile_content_subscription_default( $args ) {
    
    echo do_shortcode('[woocommerce_my_account]');
    
    }
    
    // Add Notifications Tab Which Shows For All Logged In User Roles If UM Notifications Is Installed //
    
    add_filter('um_profile_tabs', 'add_custom_profile_tab3', 19 );
    	function add_custom_profile_tab3( $notificationstab ) {
    
            if ( um_is_myprofile() ){
    
    	$notificationstab['notifications'] = array(
    		'name' => 'Notifications',
    		'icon' => 'um-faicon-bell',
            'custom' => true,
    	);
    
            }
    
    	return $notificationstab;
    
    }
    add_action('um_profile_content_notifications_default', 'um_profile_content_notifications_default');
    function um_profile_content_notifications_default( $args ) {
    
    echo do_shortcode('[ultimatemember_notifications]');
    
    }
    
    // Add Job Listing Tab Which Only Shows For Users Who Are Viewing An Employers Profile //
    
    add_filter('um_profile_tabs', 'add_custom_profile_tab4', 4 );
    	function add_custom_profile_tab4( $listingstab ) {
    
    if ( !um_is_myprofile() && ( um_user('role') == 'employer' ) ) {
    
    	$listingstab['jobslisting'] = array(
    		'name' => 'Job Listings',
    		'icon' => 'um-faicon-tasks',
            'custom' => true,
    	);
    
    }
    
    	return $listingstab;
    
    }
    add_action('um_profile_content_jobslisting_default', 'um_profile_content_jobslisting_default');
    function um_profile_content_jobslisting_default( $args ) {
    
    echo do_shortcode('[userjobs]');
    
    }
    
    // Add Job Alerts Tab Only Shows For Candidates While Viewing Their Own Profile Page //
    
    add_filter('um_profile_tabs', 'add_custom_profile_tab7', 11 );
    	function add_custom_profile_tab7( $alerttab ) {
    
    if ( um_is_myprofile() && ( um_user('role') == 'candidate') ) {
    
    	$alerttab['jobalerts'] = array(
    		'name' => 'Job Alerts',
    		'icon' => 'um-faicon-exclamation',
            'custom' => true,
    	);
    
    }
    
    	return $alerttab;
    
    }
    add_action('um_profile_content_jobalerts_default', 'um_profile_content_jobalerts_default');
    function um_profile_content_jobalerts_default( $args ) {
    
    echo do_shortcode('[job_alerts]');
    
    }
    
    // Add Job Bookmarks Tab Only Shows For Candidates While Viewing Their Own Profile Page //
    
    add_filter('um_profile_tabs', 'add_custom_profile_tab8', 12 );
    	function add_custom_profile_tab8( $bookmarks ) {
    
    if ( um_is_myprofile() && ( um_user('role') == 'candidate') ) {
    
    	$bookmarks['bookmarks'] = array(
    		'name' => 'Job Bookmarks',
    		'icon' => 'um-faicon-bookmark',
            'custom' => true,
    	);
    
    }
    
    	return $bookmarks;
    
    }
    add_action('um_profile_content_bookmarks_default', 'um_profile_content_bookmarks_default');
    function um_profile_content_bookmarks_default( $args ) {
    
    echo do_shortcode('[my_bookmarks]');
    
    }
    
    // Submit Job Tab Which Only Shows For Employers While Viewing Their Own Profile Page //
    
    add_filter('um_profile_tabs', 'add_custom_profile_tab10', 3 );
    	function add_custom_profile_tab10( $postjob ) {
    
    if ( um_is_myprofile() && ( um_user('role') == 'employer') ) {
    
    	$postjob['postjobs'] = array(
    		'name' => 'Submit Job',
    		'icon' => 'um-faicon-edit',
            'custom' => true,
    	);
    
    }
    
    	return $postjob;
    
    }
    add_action('um_profile_content_postjobs_default', 'um_profile_content_postjobs_default');
    function um_profile_content_postjobs_default( $args ) {
    
    echo do_shortcode('[submit_job_form]');
    
    }

    It’s a way but i really would like to display it on about Tab and if possible at the bottom.

    But Nice work again. I tried your custom code. That’s really cool what you did. 😉

    Hello ImagineMonkey,
    i succed doing what i wanted.

    To display custom function, you have to add action in your function.php file and add do action in the um-action-profil.php (core folder) of utimate member and place it after do_action("um_after_{$mode}_fields", $args);

    Thanks for your help anyway.

Viewing 13 replies - 1 through 13 (of 13 total)
  • The topic ‘Integrating WP Job Manager with Ultimate Members’ is closed to new replies.