• Resolved arnefallisch

    (@arnefallisch)


    Hello,

    I have a website where I use custom posts 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.
    There I put up a new tab which shows the form of a unit. I use the Pods form for this purpose inside the ob_start(), ob_end_clean():

    `ob_start();
    $miap_unit = pods(‘miap-unit’, get_the_ID());
    $fields = array( ‘unit-description’, ‘unit-news-title’, ‘unit-news’);
    echo $miap_unit->form($fields);
    $output .= ob_get_contents();
    ob_end_clean();

    Each user can only alter one unit. However I get an error when I click the ‘Save Changes’ Button. This has something to do with the ob_start() function. When I put the same code before this function it works but then form ist above the tabs and not next to it. Any idea to fix that problem?

    For the microsopces is is different. Here each user can alter several microscopes. Thus it should be possbile to select the microscope from a drop down box and then get the form with the details of the microscope.

    Best regards,
    Arne

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

Viewing 11 replies - 1 through 11 (of 11 total)
  • Plugin Author Jory Hogeveen

    (@keraweb)

    Hi @arnefallisch

    I do not understand why you are using ob_start in the first place. the form() method isn’t outputting anything, it just returns the HTML so you don’t need to use output buffering at all.
    Let me know if this helps!

    Cheers, Jory

    Thread Starter arnefallisch

    (@arnefallisch)

    Hi @keraweb

    when I do not use ob_start the form appears over of the ultimate member account tab. But I want it to appear right next to it on the rigth side. Therefore I have to use ob_start. The Pods form also shows a loading sign at the button between the last entry and the button, although it is completely loaded. The saving of the entries does not work anymore. The message that states “An error has been encountered” appears after submitting the form.

    Here is a link to the testpage of the form, where it works just fine (not a part of the ultimate member plugin):

    miap.eu/test/

    Here is the full code of the function if that helps:

    /* content in the miapunittab */
    add_filter('um_account_content_hook_miapunittab', 'um_account_content_hook_miapunittab');
    function um_account_content_hook_miapunittab( $output ){
    	ob_start();
    	
    	$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 .= ob_get_contents();
    	ob_end_clean();
    	
    	return $output;
    }

    Best regards,
    Arne

    • This reply was modified 2 years, 2 months ago by arnefallisch.
    • This reply was modified 2 years, 2 months ago by arnefallisch.
    Plugin Author Jory Hogeveen

    (@keraweb)

    Hi @arnefallisch

    As I mentioned, ob_start is only required if you cannot change the behavior of output.
    Both get_the_title() and Pods::form() are returning the values so you can omit echo and ob_start usages and assign the return values to the $output variable.
    Just make sure you don’t echo any values so you don’t need buffering.

    Cheers, Jory

    Thread Starter arnefallisch

    (@arnefallisch)

    Hi @keraweb,

    I understand what you mean now. Unfortunately that does not solve the problem. The error is still the same.

    Best regards,
    Arne

    Plugin Author Jory Hogeveen

    (@keraweb)

    Hi @arnefallisch

    Please share the error πŸ™‚

    Cheers, Jory

    Thread Starter arnefallisch

    (@arnefallisch)

    Hi @keraweb

    actually there is no error message from WordPress only the a red marked Box that states:

    An error has been encountered!

    Best regards,
    Arne

    Plugin Author Jory Hogeveen

    (@keraweb)

    Hi @arnefallisch

    Then please enable WP Debug or check your server logs!

    Debugging in WordPress

    Cheers, Jory

    Thread Starter arnefallisch

    (@arnefallisch)

    Hi @keraweb

    sorry for the misunderstanding but of course I enable the WP Debug, but it shows no errors at all. I think it must have something to do with how the ultimate member plugin calls the function containing the form.

    Best regards,
    Arne

    Thread Starter arnefallisch

    (@arnefallisch)

    Hi @keraweb

    I tried something else. I turned on the WP Debug Log instead of showing it directly and now I receive the eroor in the log

    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

    I this line 20-22 I got the following code:

    if ( ! wp_verify_nonce( $args[ 'um_account_nonce_' . $tab ], 'um_update_account_' . $tab ) ) {
    		UM()->form()->add_error( 'um_account_security', __( 'Are you hacking? Please try again!', 'ultimate-member' ) );
    	}
    Plugin Author Jory Hogeveen

    (@keraweb)

    Hi @arnefallisch

    This would be an issue for Ultimate Member to look at. Please notify their support on this error!

    Cheers, Jory

    Thread Starter arnefallisch

    (@arnefallisch)

    Hi @keraweb

    I think so too. Thank you for your support.

    Best regards,
    Arne

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