• Hi,
    I have a classifieds site where a user once registered as a (subscriber) can place his own ad.

    Currently when a user posts a new ad, it must be approved by an administrator without going live.

    what i need is:
    A user can (EDIT HIS PROFILE) directly from the frontend, but this must be sent as a review.
    Unfortunately I cannot find a viable solution for this. ??

    I’m trying to use the (REVISIONIZE) Plugin and apparently the only way to “try to get” a revision from the frontend is to use the add_action hook.

    Can you help me understand on how to create this call? I am totally confused!

    Thank you very much for your availability.

    I hope I was clear.

Viewing 4 replies - 1 through 4 (of 4 total)
  • Moderator bcworkz

    (@bcworkz)

    General information on using hooks:
    https://developer.www.ads-software.com/plugins/hooks/

    There’s no built-in mechanism to hold profile edits for review like there is for posts. You could use the “profile_update” action hook to send an email notification that there has been a change, but there’s no easy way to know what had changed.

    It would be possible to create a profile review scheme much like that for posts, but it’d be a lot more involved. It’s possible there’s an existing plugin that does this, but I don’t personally know of any.

    Thread Starter cladif

    (@cladif)

    Thanks so much for the explanation..

    Assuming that the one to review is a PostType and not a profile, how can I insert a call for review in the frontend?

    ——————
    Example.
    1) The user sends the Post from the frontend by filling out a Form, and waits for an admin to accept it to be Live.
    (To do this I used Taxonomies and some Custom Fields) age, name, city etc …
    In this way I built a profile page, but using a Post Type. Hope this makes sense !!! ??

    2) Once approved by the admin, the user has the option to edit the post and submit the review.
    ——————-

    * I managed to build Point 1

    * I would like to understand how to do point 2, right now the changes
    made ad post, they immediately become live. Instead I would have
    need to moderate it before it goes Live.

    In this case I think that with the REVISIONIZE plugin it might be possible to create a revision?

    Looking for an impossible solution !! ??

    Thread Starter cladif

    (@cladif)

    I tried this:

    1- I removed the (publish_posts) feature from the Subscriber user role

    2- I placed this code in my functions.php

    add_action('save_post', 'submit_for_review_update', 25 );
     
    function submit_for_review_update($post_id) {
     
        if (empty($post_id)) {
            return;
        }
     
        $post = get_post($post_id);
        if (!is_object($post)) { 
            return;
        }
     
        if ($post->post_type=='revision') {
           return;
        }
     
        $current_user = wp_get_current_user();    
        if (in_array('author', $current_user->roles) && $post->post_status=='publish') {
            $my_post = array(
                'ID' => $post_id,
                'post_status' => 'pending',
            );
     
            remove_action('save_post', 'submit_for_review_update', 25);
            wp_update_post($my_post);
            add_action('save_post', 'submit_for_review_update', 25);
        }
    }

    Technically this works, now when a post is edited it is automatically sent as ‘Pending’
    The problem now is that the edited post disappears from my theme until it is approved again.

    What I would need now is the status that the “Revisionize” plugin assigns, (Revision, Draft) so the old Post stays live and will be replaced when the new post is approved.

    Moderator bcworkz

    (@bcworkz)

    For posts, use the ‘wp_insert_post_data’ filter to set the post_status element to “pending”. Of course do some checks to ensure you’re only setting this for the posts that really need it.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Revisionize Function’ is closed to new replies.