• Resolved diceit

    (@diceit)


    I try to build a form, where in one of the fields the user can select one of several values provided by the post surrounding the form (e.g. a selection of posts of a custom post type or a special category)

    For customizing of admin mails I successfully provided a filter hook in lib_aux.php to insert custom values. Where can I put a filter hook to gain the same result for checkbox/radiobuttons values?

    example:
    In form setting radiobutton is set to ‘myfieldname{rbotions}’ and the filter does a string replace to set it to ‘myfieldname#option1|value1#option2|value2#option3’

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author bgermann

    (@bgermann)

    What kind of filter hook do you use?

    Thread Starter diceit

    (@diceit)

    In the meantime I got some progress.

    In a former project I needed to add some extra fields from custom post types to the admin mail. So I added in lib-aux.php ahter the “Excerpt”_replacement:

    $m 	= str_replace( '{Excerpt}',		$post_excerpt, $m );
    	
    	// DC: Hook zum Einfuegen eigener Variablen
    	$i = $page;
    	$m = apply_filters( 'cforms_apinst_email_filter', $m, $pid, $i );
    	

    and hooked the filter in my functions.php
    add_filter('cforms_apinst_email_filter','apinst_email_filter',10,3);

    to do somthing like

    function apinst_email_filter( $mailtext, $pid, $i ) {
        
    	// get custom fields
    	
    	$custom = get_post_custom($pid);
    	$myvalue=$custom["_myfield"];
    	$mailtext 	= str_replace( '{myplaceholder}',$myvalue, $mailtext );
    
        return $mailtext;
    	
    }

    In the actual project I have to do something similar when the form is rendered. I need to read the available values for a checkbox from a list of custom post types. After some research my approach is to put the hook in cform.php after line 355, so i can read and modify each field value.

    Plugin Author bgermann

    (@bgermann)

    Please have a look at https://wordpress.org/support/topic/own-variables. I am going to provide some feature like this in an upcoming version.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Filter hook for checkbox values’ is closed to new replies.