• Hello,

    I have a website where I use custom posts (Pods plugin) to generate entries for units, microscopes and workshops. Now I want specific members of different units to be able to alter their entries. Therefore I use the Ultimate Member plugin.

    I want to use a Pods form to change the entries. Here is a link to the testpage of the Pods form, where it works just fine (not a part of the ultimate member plugin):

    miap.eu/test/

    Here is the full code I wrote in my own plugin to hook into the ultimate member plugin:

    /* add new tab called "miapunittab" */
    add_filter('um_account_page_default_tabs_hook', 'my_miapunit_tab_in_um', 100 );
    function my_miapunit_tab_in_um( $tabs ) {
    	$tabs[800]['miapunittab']['icon'] = 'um-faicon-pencil';
    	$tabs[800]['miapunittab']['title'] = 'Edit MIAP Unit details';
    	$tabs[800]['miapunittab']['custom'] = false;
            $tabs[800]['miapunittab']['show_button']  = false;
    	return $tabs;
    }
    
    /* make our miapunittab hookable */
    add_action('um_account_tab__miapunittab', 'um_account_tab__miapunittab');
    function um_account_tab__miapunittab( $info ) {
    	global $ultimatemember;
    	extract( $info );
    
    	$output = $ultimatemember->account->get_tab_output('miapunittab');
    	if ( $output ) { echo $output; }
    }
    
    /* content in the miapunittab */
    add_filter('um_account_content_hook_miapunittab', 'um_account_content_hook_miapunittab');
    function um_account_content_hook_miapunittab( $output ){
    	$user = wp_get_current_user();
    	$args = array(
            'post_type' => 'miap-unit',
            'author' => $user->ID,
            'posts_per_page' => -1,
            'post_status' => 'publish'
        );
    	
        $query = new WP_Query($args);
        if ($query->have_posts()) :
    		while ($query->have_posts()) : $query->the_post();
    			
                $miap_unit = pods('miap-unit', get_the_ID());
    			$fields = array( 'unit-alert-title', 'unit-alert', 'unit-news-title', 'unit-news', 'unit-abbreviation', 'unit-affiliation', 'unit-zip-code', 'unit-city', 'unit-street', 'unit-street-number', 'unit-phone-number', 'unit-fax-number', 'unit-email', 'unit-homepage', 'unit-booking-page', 'unit-by-train', 'unit-by-car', 'unit-by-car', 'unit-description', 'unit-thumbnail', 'unit-logo');
    			echo get_the_title() . '<br />';
    			
    			// Output a form with specific fields
    			echo $miap_unit->form($fields);
    		
    		endwhile;
    	endif;
    	$output .= get_the_title() . $miap_unit->form($fields);
    	return $output;
    }

    Each user can only alter one unit. First thing to notice is that a loading circle appears at the end of the Pods form and when you click the ‘Save Changes’ Button it shows an red error box: An error has been encoutered.

    The WP error log has the entry:

    Undefined index: um_account_nonce_miapunittab in /var/www/miap.eu/wp-content/plugins/ultimate-member/includes/core/um-actions-account.php on line 20

    Any idea to fix that problem?

    Best regards,
    Arne

    • This topic was modified 2 years, 9 months ago by arnefallisch.

    The page I need help with: [log in to see the link]

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Support Aswin Giri

    (@aswingiri)

    @arnefallisch If you are submitting a form you will also need to add a nonce field and looks like you are missing the nonce field which um-action-acccount.php is looking for.

    You can set $tabs[800][‘miapunittab’][‘custom’] to true and write your own action or just add nonce fields for the form if you want to continue using default form action.

    I think the easier way is to create a custom profile tab instead of an account tab, you can just create a shortcode for your form and add it to a custom tab.

    Thread Starter arnefallisch

    (@arnefallisch)

    Dear @aswingiri

    I added a nonce field by adding the code

    $output .= '<input type="hidden" name="um_account_nonce_'. esc_attr( 'miapunittab' ).'" value="'.esc_attr( wp_create_nonce( 'um_update_account_miapunittab' ) ).'" />';

    Now I get a positiv notification “Your accout was updated successfully”. However the values are not stored in Pods.

    I also added a custom profile tab with the same Pods shortcode. In this case it works.

    Best regards,
    Arne

    Plugin Support Ultimate Member Support

    (@ultimatemembersupport)

    Hi @arnefallisch

    I suspect the issue is with rendering the form with Pods. Does it render another form tag within the Account form tag? You can do inspect elements with the chrome browser to see it.

    Regards,

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Pods Form in Ultimate Member’ is closed to new replies.