Random User Password

By default WPJobBoard will automatically login users upon registration. With this addon when registering user will not be able to enter password himself, instead he will see “Password will be emailed to you.” text (as on the screenshot below). After registration user will need to check his inbox in order to find out his password (which will be randomly generated) and login page.

This addon requires WPJobBoard 4.3.2 or newer.

random-user-password

Customization

If you wish to you can change the “Password will be emailed to you.“, using wpjb_random_user_field_text filter

add_filter("wpjb_random_user_field_text", "my_wpjb_random_user_field_text");
function my_wpjb_random_user_field_text($text) {
 return "We will send you password by email.";
}

You can change message user will see on registration success page, by default it’s “You have been registered. Your password have been emailed to you.“. If you do not want to display any message the function below should return empty string or null. Note it is possible to display different message depending on user type (employer or candidate).

add_filter("wpjb_random_user_flash", "my_wpjb_random_user_flash", 10, 2);
function my_wpjb_random_user_flash($msg, $type) {
 if($type == "employer") {
   $msg = "Registered as Employer. Check your inbox";
 } else {
   $msg = "Registered as Candidate. Check your inbox.";
 }
 return $msg;
}

Finally you can change the page to which user is redirected upon registration, by default it is default page with jobs list. Similarly like above you can redirect employer and candidate to different page.

add_filter("wpjb_random_user_redirect", "my_wpjb_random_user_redirect", 10, 2);
function my_wpjb_random_user_redirect($url, $type) {
 if($type == "employer") {
   $url = home_url()."?employer-registered";
 } else {
   $url = home_url()."?candidate-registered";
 }
 return $url;
}

Important Note If you are going to display registration success message (using wpjb_random_user_flash filter), then user should be redirected to one of WPJB pages (ie. page with one of [wpjb_*] shortcodes) or to a page where [wpjb_flash] shortcode is, otherwise the success message will display “delayed” which might confuse users.

Download

    • Greg
      Reply

      Once you download the zip file, you can install it as any other WP plugin, from wp-admin / Plugins / Add New / Upload panel.

  1. JuanF
    Reply

    Many thanks for this plugin and the code snippets.

    Very useful info on how to change messages without hacking the templates, thanks!

    The redirect-on-registration code snippet wouldn’t work for me initially, giving the error that the function was missing a 2nd argument.

    The solution turned out to be fairly easy: simply modify the add_filter line to be:
    add_filter(“wpjb_random_user_redirect”, “my_wpjb_random_user_redirect”, 10, 2);

    Hope this helps others.

    • Greg
      Reply

      Thanks for the update, you are correct the add_filter() is missing “10, 2” params, i updated the code.

Leave a Reply

Your email address will not be published. Required fields are marked *