Skip Navigation

This thread is resolved. Here is a description of the problem and solution.

Problem:

The client is developing a site using WPML with WP Job Manager and is facing an issue where bookmarks set in one language do not appear when switching to another language.

Solution:
We recommend the following steps after ensuring a full site backup:

1) Navigate to

/wp-content/plugins/wp-job-manager-bookmarks

and open

wp-job-manager-bookmarks.php

for editing.
2) Modify the code at line 356 and line 407 to include WPML filters that handle translations of bookmarked posts. This ensures that when a post is bookmarked in one language, it is recognized across all translations.

3) To prevent duplicate bookmark entries appearing for each language on the bookmark page, modify the

my-bookmarks.php

file in the

/wp-content/plugins/wp-job-manager-bookmarks/templates/

directory. Update the loop handling the display of bookmarks to check the language code of the bookmark against the current language and only display bookmarks that match.

Please refer to the following thread for more details.

https://wpml.org/forums/topic/wp-jobmanager-bookmark-in-other-language-empty/#post-16734579

If this solution does not resolve your issue or seems outdated, please check the related known issues and confirm that you have installed the latest versions of themes and plugins. If the problem persists, we highly recommend opening a new support ticket for further assistance.

This is the technical support forum for WPML - the multilingual WordPress plugin.

Everyone can read, but only WPML clients can post here. WPML team is replying on the forum 6 days per week, 22 hours per day.

Tagged: 

This topic contains 0 replies, has 1 voice.

Last updated by ericH-23 3 days, 16 hours ago.

Assisted by: Bigul.

Author Posts
January 12, 2025 at 10:10 am #16585313

ericH-23

Background of the issue:
I am developing a site and using WPML with WP Jobmanager. I am trying to bookmark (bookmark plugin of WP Jobmanager) a job in English and then switch to German.

Symptoms:
When I switch to German, the bookmark is not set.

Questions:
Can you please check this, may be this can also improved for the multilanguage usage with WPML.

January 13, 2025 at 4:23 pm #16589931

Bigul
Supporter

Languages: English (English )

Timezone: Europe/Vienna (GMT+01:00)

Hi Eric,

Welcome to the WPML support forum. I will do my best to help you to resolve the issue.

I have created a new testing environment to track this compatibility conflict in our Cloudways test server. Please click the following URL to access the site's backend. Then, check whether you can reproduce the bug.

hidden link

Please try it and let us know your feedback.

--
Thanks!

Bigul

January 15, 2025 at 10:24 pm #16599405

ericH-23

Hi,
Thanks, I installed the bookmark plugin but cannot translate the bookmark page, because automatic translation is started but cannot go further.
Can you please add the translation of the bookmark page?
Thanks, kind regards
Eric

January 16, 2025 at 10:29 am #16601271

Bigul
Supporter

Languages: English (English )

Timezone: Europe/Vienna (GMT+01:00)

Hi Eric,

Thank you for the updates. After the migration, some files were corrupted in the CloudWays test site (hidden link).

So one request, can you please check if the bug is reproducible in the following sandbox site?

hidden link

--
Thanks!

Bigul

January 16, 2025 at 11:46 am #16601739

ericH-23

Hi,
Thanks, ok, I added now the bookmark plugin and made this:

- take a test job in EN

- bookmarked the job in EN (see enclosed image)
hidden link

- change to FR

- the job have no bookmark in FR (see enclosed image)
hidden link

Because it is not another job and only a translation, the bookmark should be shown also in the translations, that is unfortunately not the case.

Please check.

Thanks, kind regards
Eric

unbookmarked job in fr.png
bookmarked job in en.png
January 20, 2025 at 5:05 am #16611689

Bigul
Supporter

Languages: English (English )

Timezone: Europe/Vienna (GMT+01:00)

Hi Eric,

Thank you for the details and reproducing the issue on the sandbox site. The ticket is escalated to our compatibility team. We will debug it further and get back to you as early as possible. Please wait.

--
Thanks!

Bigul

February 21, 2025 at 4:23 pm #16734579

Bigul
Supporter

Languages: English (English )

Timezone: Europe/Vienna (GMT+01:00)

Hi Eric,

Sorry for the late response. The fix for this issue was a bit complicated. Finally, our compatibility team found a workaround for this. Please try the following fix after a full site backup {mandatory} and make sure you are getting the expected results or not.

1) Visit */wp-content/plugins/wp-job-manager-bookmarks* folder
2) Open *wp-job-manager-bookmarks.php* file for edit
3) Scroll down to line 356
4) Make the following changes

From

				if ( $post_id && in_array( get_post_type( $post_id ), array( 'job_listing', 'resume' ) ) ) {
					
						if ( ! $this->is_bookmarked( $post_id ) ) {
							$wpdb->insert(
								"{$wpdb->prefix}job_manager_bookmarks",
								array(
									'user_id'       => get_current_user_id(),
									'post_id'       => $post_id,
									'bookmark_note' => $note,
									'date_created'  => current_time( 'mysql' ),
								)
							);
						} else {
							$wpdb->update(
								"{$wpdb->prefix}job_manager_bookmarks",
								array(
									'bookmark_note' => $note,
								),
								array(
									'post_id' => $post_id,
									'user_id' => get_current_user_id(),
								)
							);
						}

						delete_transient( 'bookmark_count_' . $post_id );
						$action_data = array(
							'success' => true,
							'note'    => $note,
						);
					}

To

				if ( $post_id && in_array( get_post_type( $post_id ), array( 'job_listing', 'resume' ) ) ) {
					// WPML Workaround for compsupp- 
					$type = apply_filters( 'wpml_element_type', get_post_type( $post_id ) );
					$trid = apply_filters( 'wpml_element_trid', NULL, $post_id, $type );
					
					$translations = apply_filters( 'wpml_get_element_translations', NULL, $trid, $type );
					foreach ( $translations as $translation ) {
						if ( isset( $translation->element_id ) ) {
							$post_id = $translation->element_id;
						}
						if ( ! $this->is_bookmarked( $post_id ) ) {
							$wpdb->insert(
								"{$wpdb->prefix}job_manager_bookmarks",
								array(
									'user_id'       => get_current_user_id(),
									'post_id'       => $post_id,
									'bookmark_note' => $note,
									'date_created'  => current_time( 'mysql' ),
								)
							);
						} else {
							$wpdb->update(
								"{$wpdb->prefix}job_manager_bookmarks",
								array(
									'bookmark_note' => $note,
								),
								array(
									'post_id' => $post_id,
									'user_id' => get_current_user_id(),
								)
							);
						}

						delete_transient( 'bookmark_count_' . $post_id );
						$action_data = array(
							'success' => true,
							'note'    => $note,
						);
					}
				}

5) Scroll down to line 407
6) Make the following changes

From

				$post_id = absint( $_GET['remove_bookmark'] );
					$wpdb->delete(
						"{$wpdb->prefix}job_manager_bookmarks",
						array(
							'post_id' => $post_id,
							'user_id' => get_current_user_id(),
						)
					);

					delete_transient( 'bookmark_count_' . $post_id );
					$action_data = array( 'success' => true );

To

				$post_id = absint( $_GET['remove_bookmark'] );

				// WPML Workaround for compsupp- 
				$type = apply_filters( 'wpml_element_type', get_post_type( $post_id ) );
				$trid = apply_filters( 'wpml_element_trid', NULL, $post_id, $type );
				
				$translations = apply_filters( 'wpml_get_element_translations', NULL, $trid, $type );
				foreach ( $translations as $translation ) {
					if ( isset( $translation->element_id ) ) {
						$post_id = $translation->element_id;
					}
					
					$wpdb->delete(
						"{$wpdb->prefix}job_manager_bookmarks",
						array(
							'post_id' => $post_id,
							'user_id' => get_current_user_id(),
						)
					);

					delete_transient( 'bookmark_count_' . $post_id );
					$action_data = array( 'success' => true );
				}

These codes will help us to bookmark and unbookmark a post in all languages. But this will cause duplicate entries on the bookmark page — one for each language. To resolve this, we recommend modifying the template to ensure bookmarks function as expected.

1) Visit */wp-content/plugins/wp-job-manager-bookmarks/templates/* folder
2) Open *my-bookmarks.php* file for edit
3) Scroll down to line 27
4) Make the following changes

From

<?php foreach ( $bookmarks as $bookmark ) : ?>

To

			<?php foreach ( $bookmarks as $bookmark ) : 
				// WPML
				$current_lang = apply_filters( 'wpml_current_language', NULL ); 
				$post_id = $bookmark->post_id;
				$bookmark_language_code = apply_filters( 'wpml_element_language_code', NULL, array('element_id' => $post_id, 'element_type' => 'job_listing' ) );
				if ( $bookmark_language_code != $current_lang ) {
					continue;
				} 
			?>

--
Thanks!

Bigul

February 24, 2025 at 7:30 pm #16742912

ericH-23

Woah, that is working well! Thanks a lot, really great. That is a good support!