• Resolved hursey013

    (@hursey013)


    Probably a bit out of scope in terms of support – but for some reason the URLs generated by the job alert email display the primary URL of a multisite network rather than the specific site’s URL. I’m messing around with the get_permalink function, substituting it with get_blog_permalink – I’ll see if that helps the situation at all.

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

Viewing 15 replies - 1 through 15 (of 16 total)
  • Plugin Author Mike Jolley

    (@mikejolley)

    Do you have it activated on the network? That may make a difference – activate all job plugins on a per-site basis. AFAIK get_permalink should reflect the site it was called from.

    Thread Starter hursey013

    (@hursey013)

    Good point, I didn’t even think about that. Just switched it over to a per site basis so I’ll see how the email looks today. Thanks for the help.

    Thread Starter hursey013

    (@hursey013)

    Installed it locally instead of network activation and still having the same issue ;-/

    Plugin Author Mike Jolley

    (@mikejolley)

    And you reverted all your customisations? We are talking about the job urls too right- I assume they are broken links if they link to the main site?

    Thread Starter hursey013

    (@hursey013)

    Yes, it’s a vanilla install.

    I have my multisite set up to have each website in a subdirectory, so the link does actually work, it just shows the primary sites URL with the subsite directory: http://screencast.com/t/I2vWIUEuh7G – the actual url should just be http://governmentjobsinarizona.com/blah-blah-blah – it’s displayed that way throughout Job Manager and the rest of the site, just this email that’s different.

    Plugin Author Mike Jolley

    (@mikejolley)

    I’m not really sure to be honest. My only thought it, if the cron job is trigged within admin, your rules may not be appling. Do permalinks in admin show the same urls?

    How do you handle that? Plugin?

    Plugin Author Mike Jolley

    (@mikejolley)

    Sorry for my spelling, phone keyboard :p

    Thread Starter hursey013

    (@hursey013)

    Yes when I’m in the admin section I get the same long URL with the primary site and the sub site in a directory. Somehow on the frontend it’s all magically fixed, but yeah that same logic doesn’t seem to be applied behind the scenes with the email. I did find a solution, wp-job-manger-template.php, I had to change this function to use get_blog_permalink:

    function get_the_job_permalink( $post = null ) {
    	$post = get_post( $post );
    	$link = get_blog_permalink( $post->blog_id, $post );
    
    	return apply_filters( 'the_job_permalink', $link, $post );
    }

    Is it possible to override this within functions.php or something to avoid it being overwritten – and do you see any potential issues with this?

    Plugin Author Mike Jolley

    (@mikejolley)

    You can filter the the_job_permalink.

    add_filter( 'the_job_permalink', 'multisite_the_job_permalink', 10, 2 );
    function multisite_the_job_permalink( $link, $post ) {
      $post = get_post( $post );
      return get_blog_permalink( $post->blog_id, $post );
    }
    Thread Starter hursey013

    (@hursey013)

    Awesome, thank you, first WP site so I’m still catching on. There is one other reference that I need to update – the job-alerts URL at the bottom of the email. It’s within the format_email function of class-wp-job-manager-alerts-notifier.php:

    $replacements = array(
    			'{display_name}'    => $user->display_name,
    			'{alert_name}'      => $alert->post_title,
    			'{alert_expirey}'   => $alert_expirey,
    			'{alert_next_date}' => date_i18n( get_option( 'date_format' ), $next ),
    			'{alert_page_url}'  => get_blog_permalink( $alert->blog_id, get_page_by_path( get_option( 'job_manager_alerts_page_slug' ) )->ID ),
    			'{jobs}'            => $job_content
    		);

    Is it possible to override that with a filter hook as well? Here’s my best guess:

    add_filters( 'job_manager_alerts_template', 'multisite_job_manager_alerts_template', 10, 1 );
    	public function multisite_job_manager_alerts_template( $alert, $user, $jobs ) {
    
    		$replacements = array(
    			'{display_name}'    => $user->display_name,
    			'{alert_name}'      => $alert->post_title,
    			'{alert_expirey}'   => $alert_expirey,
    			'{alert_next_date}' => date_i18n( get_option( 'date_format' ), $next ),
    			'{alert_page_url}'  => get_blog_permalink( $alert->blog_id, get_page_by_path( get_option( 'job_manager_alerts_page_slug' ) )->ID ),
    			'{jobs}'            => $job_content
    		);	
    
    }
    Plugin Author Mike Jolley

    (@mikejolley)

    There isn’t a filter for that one unfortunately.

    Are you using a plugin or anything for these permalinks? I wonder if its only targeting non-admin requests…

    Thread Starter hursey013

    (@hursey013)

    I’m using this: http://wordpress.org/plugins/wordpress-mu-domain-mapping/installation/ – is that what you are referring to?

    Thread Starter hursey013

    (@hursey013)

    I think I’m finally catching on to what you are getting at – I’ve modified some of the settings in that domain mapping plugin, to see if that may be the issue: http://screencast.com/t/gVP4VWP1p6K I previously had “Redirect administration pages to site’s original domain” checked.

    Is there a way to force send out the job alert email? I tried changing the publish date of the alert page in phpmyadmin but that didnt seem to trick it into sending it again.

    Plugin Author Mike Jolley

    (@mikejolley)

    It’s triggered by a cron job. Have to wait I’m afraid unless you can find a WP cron plugin which lets you reschedule or trigger.

    Thread Starter hursey013

    (@hursey013)

    Yeah… adjusting the settings of the domain mapping plugin did the trick. I deselected the “Redirect administration pages to site’s original domain (remote login disabled if this redirect is disabled)” setting and it fixed the URLs in the email. For others reference, see here for the domain mapping settings I used: http://screencast.com/t/pPccNbptkK

    Thanks for your help Mike.

Viewing 15 replies - 1 through 15 (of 16 total)

The topic ‘Job Alerts w/ Multisite’ is closed to new replies.