WordPress.org

Forums

WP-Members
[resolved] Radiobox Register Form (7 posts)

  1. jrtideias
    Member
    Posted 1 year ago #

    Hi everbody,
    I'd like add a radio buttons. Is it possible using wpmem_register_form filter hook? Or anybody know how can I add it?

    thanks

    http://wordpress.org/extend/plugins/wp-members/

  2. Chad Butler
    Member
    Plugin Author

    Posted 1 year ago #

    Radio buttons are not natively supported yet, but may be in the future.

    Yes, you could add them with the wpmem_register_form filter. I would create a placeholder field (text) in the field manager and then use PHP's str_replace to replace the text field with the radio button.

  3. jrtideias
    Member
    Posted 1 year ago #

    Ok.
    Thanks!

  4. jrtideias
    Member
    Posted 1 year ago #

    Hey,
    sorry I'm not a programmer, so I tried this:

    add_filter( 'wpmem_register_form', 'input_replace' );
    function input_replace( $form )
    {
    
    	$old = array(  'test','text', '' );
    	$new = array(  'test','radio', 'sim' );
    
    	$form = str_replace( $old, $new, $form );
    
    	return $form;
    }
    
    and this:
    add_filter( 'wpmem_register_form', 'input_replace' );
    function input_replace{
    	$old = '<input type="text" class="textbox" value="" id="test" name="test">';
    	$new = '<<input type="radio" name="test" value="yes">yes<input type="radio" name="test" value="no">no';
    
    	$form = str_replace( $old, $new, $form );
    
    	return $form;
    }

    [Please post code & markup between backticks or use the code button. Your posted code may now have been permanently damaged by the forum's parser.]

    but doesn't work...

    Can you help me, please?

  5. Chad Butler
    Member
    Plugin Author

    Posted 1 year ago #

    I'm not sure what you are doing with the first one, but the second has a couple of problems.

    First, you neglected to include a section for arguments when you defined your function:

    function input_replace{

    This will create a syntax error as your function must have () after the function name. And in this case, you need to pass the generated form to the function as an argument:

    function input_replace( $form ) {

    Second, the string that you are searching for (defined as $old in your code) MUST be an EXACT match of what is generated in the form. I would suggest the following:

    • I assume that you have created this field as a placeholder in the plugin's field manager. If not, you need to do that.
    • Bring up the form in your browser and view source in your browser.
    • Find the field in the html source and copy/paste that into your code as the string you are searching for.

    My guess is the string you should be searching for in this should look something like this (assuming you called it "test" and it is a text field):

    <input name="test" type="text" id="test" value="" class="textbox" />

  6. Creative Paul
    Member
    Posted 1 year ago #

    Great Man !

  7. ravi.kulkarni
    Member
    Posted 1 year ago #

    Hi all,
    I am using WP-member plugin , now to add custom fields for simple one it work,but for fields like hobbies with chatterboxes have values like 'reading', 'writing',etc
    Now how to add it Please give me answer with which file or form admin how to change it. with simplified code.So on registration page look like
    Hobbies:
    check box option1
    check box option2

    Please provide me solution

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • WP-Members
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic