• Resolved rcwdm

    (@rcwgsy)


    Hi,

    I see you have handled a query like this, but I am trying to get this to work with a custom role. Or any role actually.

    How would you edit this if you wanted a ‘customer’ to not be able to publish more than one CPT from a specific ACF form?

    I’m not getting any joy at the moment.

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

Viewing 5 replies - 16 through 20 (of 20 total)
  • Plugin Author Konrad Chmielewski

    (@hwk-fr)

    Hello,

    I’m not really sure to understand what you mean by “Changing users role after then publish a form”. But you can trigger a custom action and perform custom task when a post is published using the acfe/form/submit/post hook. See documentation.

    I would really recommend to get some assistance with a freelance developer or company to help you dig those concepts and understand how to achieve what you want to do. Remember that you’re trying to use multiple technologies together (Oxygen Builder, ACF Pro, ACF Extended…) which can become quite complex, since some of them are tech-savy (ACF/ACF Extended). Also front-end forms, especially front-end publishing, are one of the most advanced web applications, with tons possibilities and layers of complexity (from a simple form to a full CRM).

    So it’s really hard to discuss and understand everything you need and where you want to go on a support forum like this one.

    I can answer precise questions or check bug reports, but I cannot suggest/discuss solutions to build web applications, it would take too much time.

    Regards.

    Thread Starter rcwdm

    (@rcwgsy)

    Looks like I may need to.

    But, what I meant was as the user submits the form, the users role such as ‘subscriber’ changes to ‘contributor’.

    It would open up far simpler hide/show condition options for me.

    Plugin Author Konrad Chmielewski

    (@hwk-fr)

    Yes, you can use the acfe/form/submit/post hook to perform that action. See documentation.

    To change the user role, please refer to support threads:

    https://wordpress.stackexchange.com/questions/4725/how-to-change-a-users-role
    https://usersinsights.com/wordpress-custom-role/
    https://tommcfarlin.com/wordpress-user-role/

    Usage example:

    add_action('acfe/form/submit/post/form=my-form', 'my_form_submit', 10, 5);
    function my_form_submit($post_id, $type, $args, $form, $action){
        
        $current_user_id = get_current_user_id();
        
        if(!$current_user_id){
            return;
        }
        
        // retrieve user
        $user = new WP_User($current_user_id);
    
        // remove role
        $user->remove_role('subscriber');
    
        // add role
        $user->add_role('contributor');
        
    }
    

    It’s probably not perfect since you’ll probably have to check that the current user is a “old role” before switching to “new role”, to avoid add role to the admin if he does the test for example. Please refer to other code and online tutorials if needed.

    Regards.

    Thread Starter rcwdm

    (@rcwgsy)

    Thanks for your help. I’ll look into it.

    Plugin Author Konrad Chmielewski

    (@hwk-fr)

    You’re welcome!

    Thanks for the nice review ??

    Regards.

Viewing 5 replies - 16 through 20 (of 20 total)
  • The topic ‘Limit ability to publish form’ is closed to new replies.