PHP – sMyles Plugins https://plugins.smyl.es WordPress and WHMCS Plugins Tue, 02 Sep 2025 21:17:53 +0000 en-US hourly 1 https://wordpress.org/?v=4.6.29 Give user free/trial visibility package on registration https://plugins.smyl.es/docs-kb/give-user-freetrial-visibility-package-on-registration/ Mon, 02 Apr 2018 21:29:33 +0000 https://plugins.smyl.es/?post_type=bwl_kb&p=152404 After a few request from clients, I have come up with a method that you can automagically give a user a package when they register on your site, which can be used as a way to provide a “free trial” or “free” package initially.  This does require adding some PHP code to your child theme’s functions.php file (or using the Code Snippets plugin).

As of  version 1.2.1+ a feature has been added to “give” a package to user on registration in the product configuration page.  You can then set the product  as hidden, and users won’t be able to select the package from package selection page, but will be given the package on registration.

I have been looking at different ways to integrate this into the plugin for a future update, probably when creating a new visibility package you can select a checkbox that says something like “Hide from cart, and assign to new users on registration”, but if you would like this functionality before I can release this update, here’s some example code to do this:

You will notice there are two actions, one for Job and one for Resumes … if you only need this for Job packages, or only for Resume packages, you can omit the add_action and the associated function (do not omit the function to check user roles).  As an example, if you only needed this for Job Packages, you would use this code instead:

You will also notice in the code that there is a check for the User Role before assigning a package.  You can change this to any specific user role you want, but in these examples the user role of employer is used for Job Visibility packages, and candidate for Resume Visibility Packages.

]]>
How to customize the phone field type https://plugins.smyl.es/docs-kb/how-to-customize-the-phone-field-type/ Mon, 13 Apr 2015 18:19:48 +0000 https://plugins.smyl.es/?post_type=bwl_kb&p=60443 Want to auto detect the user’s country based on their IP?  Maybe you want to have the phone field type default to a specific country?  What about putting preferred countries at the top of the dropdown list?  You can do all of this and more with the new filter added in WP Job Manager Field Editor version 1.2.6.

Overview

The open source jQuery plugin used for the phone field type is called International Telephone Input, and you can find all the information you would need about it (including details on the available configuration and options) on GitHub:

https://github.com/Bluefieldscom/intl-tel-input

As the latest version from above is newer than the current version included with the field editor, please see this URL for documentation on the version included with the field editor:

https://github.com/jackocnr/intl-tel-input/tree/8a2364bc0459fce934d7cf04a82823db63e7944b

In order to modify any of the default options you will need to use a WordPress Filter that is placed in your theme’s functions.php  file.  The filter you will need to use to override the default arguments is:

job_manager_field_editor_phone_args

Below you will see the code directly from the plugin that shows the currently supported options/configurations:

$phone_args = apply_filters( 'job_manager_field_editor_phone_args', array(
	'allowExtensions'    => false,
	'autoFormat'         => true,
	'autoHideDialCode'   => true,
	'autoPlaceholder'    => true,
	'defaultCountry'     => '',
	'ipinfoToken'        => '',
	'nationalMode'       => false,
	'numberType'         => 'MOBILE',
	'preferredCountries' => array('us', 'gb'),
	'utilsScript'        => WPJM_FIELD_EDITOR_PLUGIN_URL . '/assets/js/phoneutils.min.js'
	)
);

 

You should never need to modify the utilsScript value (unless you really know what you’re doing).  Make sure to read the GitHub page for specific details on the values before changing them.

Example Configuration

Note: any options that take country codes should be ISO 3166-1 alpha-2 codes

For this example we will be changing the phone field type to automatically detect and select the user’s country based on their IP.  If the location can not be determined by IP, we will have it default to France.  We will also set the countries to show at the top of the dropdown list to France, and Germany.

Phone Field Type Custom Configuration

If you read the documentation from the GitHub page, you will see that if we set the value of defaultCountry to auto it will automatically attempt to detect the user’s location based on their IP.  That is why in the example screenshot above you can see the country shows USA, but the other countries at the top are France and Germany.  This is because my IP address is located in the USA and it automatically set it to USA.

To set the countries at the top of the dropdown list, we will use preferredCountries

This would be the final code you would need to add to your functions.php file, I will go over each part below.

add_filter( 'job_manager_field_editor_phone_args', 'my_custom_phone_args' );

function my_custom_phone_args( $args ){

	$args['preferredCountries'] = array( 'fr', 'de' );
	$args['defaultCountry'] = 'auto';

	return $args;
}

 Example Breakdown

So the first code we need to add is the add_filter  which tells WordPress to run our custom function so we are able to modify the values:

add_filter( 'job_manager_field_editor_phone_args', 'my_custom_phone_args' );

The code above adds a hook to the field editor filter, and then runs my_custom_phone_args  function whenever the filter is called from the plugin.

The next code added is the function that is called:

function my_custom_phone_args( $args ){

	$args['preferredCountries'] = array( 'fr', 'de' );
	$args['defaultCountry'] = 'auto';

	return $args;
}

As you can see in the function above, $args  is passed to the function which includes all of the default arguments.  Using standard PHP we can modify those values as needed, and as you see at the bottom, then return the $args  back to the hook.  You MUST return the $args  otherwise you will have issues.  Using the country codes obtained from the ISO 3166-1 alpha-2 codes, the possibilities are endless!

This same method can be used to override any of the other default configuration values, but PLEASE make sure to read the documentation on the GitHub page to make sure you use the right values.

If you change any of the boolean values (true or false), do not place them in quotes, they should be just like the values you see above in the default configuration.

]]>
How to change button, or other text on entire WordPress site https://plugins.smyl.es/docs-kb/how-to-change-button-or-other-text-on-entire-wordpress-site/ Mon, 13 Oct 2014 23:28:18 +0000 https://plugins.smyl.es/?post_type=bwl_kb&p=13230 I have received a few requests from users about how they can change the wording on things such as buttons, or even “Resumes” in general.  Even though this is out of the scope of the WP Job Manager Field Editor plugin, I will show you in this tutorial how to easily change pretty much any wording on your WordPress site thanks to the integrated translation functionality and actions.

You have two methods to do this, you can either use the free WordPress Plugin called SayWhat or you can add your own PHP code in your functions.php  file (in your theme directory).

Say What? Plugin

This is very straight forward, enter the exact phrase you are looking to replace and voila!  Make sure you set the correct text domain otherwise it will not work correctly!  You can find the correct text domain by looking at the code of the plugin you want to change the text in, and where you see the string it should look similar to this:

__( ‘Company Details’, ‘wp-job-manager’ );

The text domain is the second argument in the function call.  In the example above, the text domain is wp-job-manager

Some common text domains:

WP Job Manager: wp-job-manager

WP Resume Manager: wp-job-manager-resumes

WP Job Manager Field Editor: wp-job-manager-field-editor

Check the plugin’s site for more details and documentation:
https://wordpress.org/plugins/say-what/screenshots/

I recommend you use the Say What? plugin if you are not comfortable using PHP!

PHP Code

You can also easily replace text by using the example below and placing it inside your functions.php  file.  In the example below i’m going to show you how to replace the Update resume text in the button created by WP Job Manager Resumes.

First you need to find what the exact string is that was used in the code.  A lot of times you can do this by simply looking the in “lang” or “language” folder for the translation files, but for this example I will point out the exact spot in the code:

get_job_manager_template( 'resume-submit.php', array(
	'class'              => __CLASS__,
	'form'               => self::$form_name,
	'resume_id'          => self::get_resume_id(),
	'action'             => self::get_action(),
	'resume_fields'      => self::get_fields( 'resume_fields' ),
	'submit_button_text' => __( 'Update resume →', 'wp-job-manager-resumes' )
), 'wp-job-manager-resumes', RESUME_MANAGER_PLUGIN_DIR . '/templates/' );

As you can see in the highlighted section above on line 7 the __( ‘Translatable Text’ )  internal WordPress function is being called and this is how you are able to change the text.  Using that exact string, you can see in the code below how to change the text.

add_filter( 'gettext', 'replace_preview_resume_text', 10, 3 );

function replace_preview_resume_text( $translation, $text, $domain ){

    if( $text === 'Update resume →' ) {
        $text = 'Update Profile →';
    }

    return $translation;
}

 

I will not provide support regarding this and I have created this basic tutorial just for reference.

]]>
How to output custom fields on job and/or resume listings https://plugins.smyl.es/docs-kb/how-to-output-custom-fields-on-job-andor-resume-listings/ Mon, 25 Aug 2014 20:38:11 +0000 https://plugins.smyl.es/?post_type=bwl_kb&p=2734 As of version 1.1.9 there is an integrated auto output feature!:

https://plugins.smyl.es/docs-kb/field-output-configuration/

As of version 1.1.5 there is an integrated widget you can use to output a custom field:

https://plugins.smyl.es/blog/widget-now-included-with-wp-job-manager-field-editor/

As of version 1.2.0 the widget has undergone a huge overhaul and should have all the same options as auto output:

https://plugins.smyl.es/docs-kb/using-the-integrated-widget/

You can also customize your own job/resume listing template file, and use a Shortcode or PHP Function to output the value of the custom field.

You can find more information about templates from the WP Job Manager Wiki.

You can also find tons of video tutorials on YouTube here:

https://www.youtube.com/playlist?list=PLa5IXe9CvtRhvmXN1QHIIh73bOyOA8fO5

If you have any questions or need help, feel free to open a support ticket or contact me for further assistance.

]]>
Output custom field values using PHP https://plugins.smyl.es/docs-kb/output-custom-field-values-using-php/ Mon, 25 Aug 2014 15:51:30 +0000 https://plugins.smyl.es/?post_type=bwl_kb&p=2735 To output any custom fields you have created you can either use Shortcodes or one of the following PHP functions to output the custom field values.

Right now there are multiple functions available, one for job fields, company fields, resume fields, etc. This is for any future enhancements, but currently all functions do the same thing (so technically you could use get_resume_field and with details for a job listing and it will still display right. My Suggestion is to use job, company, or resume for the specific field, and if you are not sure then you can use custom field function.

You can find all of these functions and details on them in the includes/functions.php file under the wp-job-manager-field-editor plugin directory.

I also recommending looking through my Gist on GitHub as this is where I frequently post examples (PHP, JS, etc) for support tickets and I may already have some example code you need:

https://gist.github.com/tripflex

Available Functions


get_job_field / the_job_field

get_job_field( $field_slug, $job_id, $args ) or the_job_field( $field_slug, $job_id, $args )

  • $field_slug is the meta key for the field
  • $job_id optional The job ID you want to get the value from, if $job_id is not specified it will use the current job listing.
  • $args optional Array with key => value configuration (can be any configuration attribute available in shortcodes). See below for more details.
  • Using get_job_field will return the value, using the_job_field will echo/print out the field.

get_company_field / the _company_field

get_company_field( $field_slug, $job_id, $args ) or the_company_field( $field_slug, $job_id, $args )

  • $field_slug is the meta key for the field
  • $job_id optional The job ID you want to get the value from, if $job_id is not specified it will use the current job listing.
  • $args optional Array with key => value configuration (can be any configuration attribute available in shortcodes). See below for more details.
  • Using get_company_field will return the value, using the_company_field will echo/print out the field.

get_resume_field / the_resume_field

get_resume_field( $field_slug, $resume_id, $args ) or the_resume_field( $field_slug, $resume_id, $args )

  • $field_slug is the meta key for the field
  • $resume_id optional The resume ID you want to get the value from, if $resume_id is not specified it will use the current resume listing.
  • Using get_resume_field will return the value, using the_resume_field will echo/print out the field.

get_custom_field / the_custom_field

get_custom_field( $field_slug, $post_id, $args ) or the_custom_field( $field_slug, $post_id, $args )

  • $field_slug is the meta key for the field
  • $post_id optional The resume/job ID you want to get the value from, if not specified it will use the current resume/job listing.
  • $args optional Array with key => value configuration (can be any configuration attribute available in shortcodes). See below for more details.
  • Using get_custom_field will return the value, using the_custom_field will echo/print out the field.

Example Usage

Say I wanted to output a new custom field I created with a meta key of job_salary, this is the PHP code you would add to your job listing template file:

Using `get_job_field`

$salary = get_job_field( 'job_salary' );
echo $salary;

Or you could simply use the_job_field function instead:

Using the_job_field

the_job_field( 'job_salary' );

Both of the examples above would output the value of the field if it was set for the job listing. This same method can be used for company, resumes, or any other custom fields.

Show image from custom upload field

$image_url = get_company_field( 'company_office_photo' );
echo '<img src="' . $image_url '" />';

 

Passing $args configurations

You can pass any configuration arguments/attributes available in shortcodes, when calling PHP functions.  If you do not want to define the listing ID, and want to force my plugin to automagically detect the listing id, just pass null to the listing id, like so:

the_job_field( 'some_job_field', null, array( 'output_as' => 'text' ) );

As you can see above, just pass null as the second parameter, and then in the third parameter you can define configurations.

Here’s a few more examples for reference:

Output “another_custom_field” showing label, and with full wrapper HTML element enabled

the_custom_field( 'another_custom_field', null, array( 'output_show_label' => true, 'output_enable_fw' => true ) );

Define arguments configuration in separate variable

$website_link_args = array(
    'output_as' => 'link',
    'output_show_label' => true,
    'output_classes' => 'some-class another-one',
);

the_custom_field( 'website_link', null, $website_link_args );

 

]]>