set signature line colour?

By: Geert Leysen | Asked: 04/24/2024
ForumsCategory: Code Snippetsset signature line colour?
Geert Leysen asked 3 months ago

Hi,
I found the following developer hook to customize signature options:

add_filter( 'frm_sig_output_options', 'sig_output_options' );
function sig_output_options( $options ) {
  $options['bgColour'] = 'transparent';
  return $options;
}

However it doesn't show what other options there are to set...

I would like to set the line colour of the signature.

Anyone have a list of all the posible options names that I can set like this?   THx!    

1 Answers
Victor Font answered 3 months ago
This is a great example where knowing how to read code comes into play to solve your problem. First, you have to locate the filter in Formidable's source. My codex will help with that: https://formidable-masterminds.com/codexv2-hook-detail/?codex_id=4223&entry_type=Filter&return_page=codexv2-filter-list#field_4223_detail_link
Victor Font replied 3 months ago

The filter actually has 2 parameters:

apply_filters( 'frm_sig_output_options', $signature_output, array( 'field' => $field ) );

The Formidable developers only exposed the background color for you to change, but when you look at the code, the $signature_output merged to an unexposed array named $signature_opts with the PHP array_merge function.

https://www.php.net/manual/en/function.array-merge.php

These are the important features of array_merge:

"Merges the elements of one or more arrays together so that the values of one are appended to the end of the previous one. It returns the resulting array.

If the input arrays have the same string keys, then the later value for that key will overwrite the previous one. If, however, the arrays contain numeric keys, the later value will not overwrite the original value, but will be appended."

The good news is that the Formidable developers use string keys to define the elements of the $signature_opts array, which means you can override any of those values by adding an identical element to your filter.

These are the values in $signature_opts:

$signature_opts = array(
'id' => $field->id,
'width' => $values['size'],
'height' => $values['max'],
'line_top' => round( $values['max'] * 0.7 ) + 0.5, // use .5 for crisp line.
'line_margin' => $values['size'] * 0.05,
'line_color' => $border_color,
'line_width' => $hide_tabs ? 0 : 1,
);

I hope this helps.

Geert Leysen replied 3 months ago

Thx for that.... I tried with line_color however it doesn't seem to influence the drawing line.
Anyway, I made the background image (that I've set to draw over) a different color, so now the drawing line is showing ok, eventhough I didn't change it's color.

If someone does get it to work, do let me know!.. just curious 😉

Making the Best WordPress Plugin even better - Together

Take on bigger projects with confidence knowing you have access to an entire community of Formidable Experts and Professionals who have your back when the going gets tough. You got this!
Join the community
crossarrow-right