Title: Conditional contact fields?
Last modified: February 23, 2022

---

# Conditional contact fields?

 *  [curtismchale](https://wordpress.org/support/users/curtismchale/)
 * (@curtismchale)
 * [4 years, 3 months ago](https://wordpress.org/support/topic/conditional-contact-fields/)
 * We need to be able to show the email (as it currently works) or if there is no
   email link to a URL for a contact page.
 * Is there a way that we can do this currently? I’m happy to write some code to
   make this possible if you have some direction about how you’d like it added to
   the plugin.
 * I realize you are setup so I could override the template and display my own custom
   frontend view, but I don’t see a way currently to add a field to the admin area
   of the site and I note that you use `sanitize_email` as you save the code so 
   we can’t just put a URL in there as it would be sanitized and then not what we
   want.

Viewing 2 replies - 1 through 2 (of 2 total)

 *  Plugin Author [Brett Shumaker](https://wordpress.org/support/users/brettshumaker/)
 * (@brettshumaker)
 * [4 years, 3 months ago](https://wordpress.org/support/topic/conditional-contact-fields/#post-15397365)
 * Hi Curtis –
 * > Is there a way that we can do this currently?
 * Admittedly, I don’t have this aspect of the plugin set up as I’d like but this
   should still be possible using the `sslp_replace_formatted_values_filter` (assuming
   you’re using the `[staff-email-link]` tag). Again, this is suboptimal, but that
   filter provides an array (non-associative 😞) of values that can be changed. 
   The email link is in the 3rd index there. Something like this could work:
 *     ```
       function sslp_replace_formatted_values_filter_function( $replace_formatted_values, $post_id ) {
           // If there's an empty mailto link, replace it with a link to the contact page.
           if ( strpos( $replace_formatted_values[3], 'href="mailto:"' ) !== false ) {
               $replace_formatted_values[3] = '<a href="/contact-us" title="Contact Us">Contact Us</a>';
           }
   
           return $replace_formatted_values;
       }
       add_filter( 'sslp_replace_formatted_values_filter', 'sslp_replace_formatted_values_filter_function', 10, 2 );
       ```
   
 * Let me know if that would work for your use case.
 * Thanks!
 *  Thread Starter [curtismchale](https://wordpress.org/support/users/curtismchale/)
 * (@curtismchale)
 * [4 years, 2 months ago](https://wordpress.org/support/topic/conditional-contact-fields/#post-15439092)
 * [@brettshumaker](https://wordpress.org/support/users/brettshumaker/) not quite.
   We need to have both fields in the admin area and then I can display whichever
   one has data. As I said in Slack, I have development time to help build this.
   I just need direction from you so that I don’t build something you don’t want
   in the plugin.
 * Ideally, I’ll help build, or totally build this feature that you have said in
   other channels you want to add.

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Conditional contact fields?’ is closed to new replies.

 * ![](https://ps.w.org/simple-staff-list/assets/icon-256x256.png?rev=2718196)
 * [Simple Staff List](https://wordpress.org/plugins/simple-staff-list/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/simple-staff-list/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/simple-staff-list/)
 * [Active Topics](https://wordpress.org/support/plugin/simple-staff-list/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/simple-staff-list/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/simple-staff-list/reviews/)

 * 2 replies
 * 2 participants
 * Last reply from: [curtismchale](https://wordpress.org/support/users/curtismchale/)
 * Last activity: [4 years, 2 months ago](https://wordpress.org/support/topic/conditional-contact-fields/#post-15439092)
 * Status: not resolved