Forum Replies Created

Viewing 4 replies - 1 through 4 (of 4 total)
  • Thread Starter NeoCrash

    (@neocrash)

    Awesome, all understood.

    Is true about always returning a value in a function, is coding 101, hehe I missed that.

    I′ll modify the argument, as you suggested, so the $form[‘post_id’] is as default, to avoid issues.

    Thank you so much

    Thread Starter NeoCrash

    (@neocrash)

    Solution founded while sleeping, I’m sure you all have these epiphanies while sleeping ??

    I just need to pass the post_id using a form argument.
    I defined the form argument while loading the form

    add_filter('acfe/form/load/form=prop_edit', 'my_form_settings', 10, 2);
    function my_form_settings($form, $post_id){
        
        // Add currently eddited post_ID got it from the URL parameter
        $form['post_id'] = $_GET['art'];
        
        return $form;
        
    }

    Finally, I can use this form argument, during validation, to access to the edited post ID.

    add_action('acfe/form/validation/form=prop_edit', 'valida_edicion', 10, 2);
    function valida_edicion($form, $post_id){
         $id_actualizar = $form['post_id'];
    
        //Note that $post_id argument only returns the post ID of the page where the form is rendered, not the post_id of the edited post (read original support request post).
       //I call the function that validates if the user is administrator, editor or is the author of the currently edited post. It needs the post_id.
    
       if (!permiso_modificar($id_actualizar)){
             acfe_add_validation_error('prop_estado', 'No tienes permiso para modificar esta propiedad. Si considera que a ocurrido un error, contacte soporte técnico.');
         }
    }

    Left here the whole history for the next users.

    • This reply was modified 3 years ago by NeoCrash.

    This also happens to me. The icons are shown at the bottom of every peepso page even if this is all options are deactivated.
    Any idea why? and more importantly how to fix it?

    I guess you can use something like
    if (!current_user_can(‘administrator’) && !is_admin()) {
    /*place your code here
    for no admin users*/
    }

Viewing 4 replies - 1 through 4 (of 4 total)