• Resolved webfantastic

    (@webfantastic)


    Hi!

    How to display the form on the account page as shown in the demo screenshots?

    How do I show the form for saving the chat id from the user? It didn’t work out for me. Is there a shortcode to insert the form on the account page?

Viewing 12 replies - 1 through 12 (of 12 total)
  • Plugin Author Irshad Ahmad

    (@irshadahmad21)

    Hi,

    What do you see on the account page?

    Can you please share a screenshot?

    Thread Starter webfantastic

    (@webfantastic)

    We have a personal account that differs from the standard one. It would be better to make a shortcode that allows the administrator to insert a telegram binding form in the user’s personal account. Now your form is not displayed, because the Elementor constructor is used to configure your personal account and these are not standard wordpress templates.

    Please make a shortcode? I’ve already tried using the function myself, but I didn’t manage to do it well.

    • This reply was modified 11 months, 2 weeks ago by webfantastic.
    Plugin Author Irshad Ahmad

    (@irshadahmad21)

    Adding a shortcode will not help because form submission needs to be handled server-side to save the Telegram ID, which is different for different forms/plugins.

    So, if you can create an input that saves the value to user meta table with the key as wptelegram_user_id, you should be good to go. Just ensure to display all the instructions as given in the default user edit page.

    Thread Starter webfantastic

    (@webfantastic)

    When editing a user in the administrative part, I see a field for entering his chat id. I am interested in the question of how to show this field in the user’s personal account so that he can enter the chat id himself and save it. I couldn’t do it. Therefore, I asked for a shortcode so that I could create a page in the user’s personal account where he would change his chat id and instructions on how to enable notifications. So that as an administrator I don’t do it manually.

    Thread Starter webfantastic

    (@webfantastic)

    the shortcode for the output of this part https://prnt.sc/OXkzKaTL9oqK

    Maybe you can tell me which function to use so that I can call this form if I have a non-standard control panel for users or I want to place this form on a separate page.

    Thanks

    • This reply was modified 11 months, 2 weeks ago by webfantastic.
    Plugin Author Irshad Ahmad

    (@irshadahmad21)

    You can create the form input howsoever you want, you just need to ensure that the value gets saved to wptelegram_user_id user meta key.

    Thread Starter webfantastic

    (@webfantastic)

    Thank you, but you probably don’t understand what I’m asking? I ask you to give instructions on how to show your plugin settings in the frontend user profile settings. As in the screenshot https://prnt.sc/OXkzKaTL9oqK. How can this be output by a function or a shortcode? Thanks

    Plugin Author Irshad Ahmad

    (@irshadahmad21)

    The plugin cannot add the field to every front-end out there. It’s simply not possible.

    You will need to do as suggested above.

    Thread Starter webfantastic

    (@webfantastic)

    You show a screenshot on the plugin page where it is displayed. How impossible? If you provided a shortcode for the output of the form, then no one would ask about it and users would have no problems with integration. Now it looks like an unfinished product. Because there is a field for the user to enter his chat id in the backend, but you have not provided anything for the frontend.

    Thread Starter webfantastic

    (@webfantastic)

    Because your support is quite weak. I wouldn’t buy the Pro version of your plugin. For the first time I come across such a thing that the user himself offers a solution to the developer. This function will allow you to insert the shortcode [wptelgram_user_id_form] to any place on the site on the user profile page to display the chat id input form for linking the telegram.

    function wptelegram_user_id_form() {
        // Get the current user ID
        $user_id = get_current_user_id();
        
        // Get the saved value of the "wptelegram_user_id" field for the current user
        $saved_value = get_user_meta($user_id, 'wptelegram_user_id', true);
        
        // Check if the form has been submitted
        if (isset($_POST['wptelegram_user_id'])) {
            // Sanitize the input value
            $new_value = sanitize_text_field($_POST['wptelegram_user_id']);
            // Update the user meta with the new value
            update_user_meta($user_id, 'wptelegram_user_id', $new_value);
            // Redirect the user back to the same page to prevent resubmission
            wp_redirect($_SERVER['REQUEST_URI']);
            exit;
        }
        
        // Generate the HTML for the form with inline styles
        $html = '<form method="post" action="">';
        $html .= '<label for="wptelegram_user_id" style="display:block;margin-bottom:10px;font-size:14px;">Telegram ID:</label>';
        $html .= '<input type="text" name="wptelegram_user_id" id="wptelegram_user_id" value="' . esc_attr($saved_value) . '" style="width:100%;padding:10px;font-size:14px;border:1px solid #ccc;border-radius:4px;box-sizing:border-box;margin-bottom:20px;height:40px;">';
        $html .= '<input type="submit" value="Save" style="background-color:#0085ba;color:#fff;border:none;padding:10px 20px;border-radius:4px;cursor:pointer;font-size:14px;">';
        $html .= '</form>';
        
        // Output the HTML
        return $html;
    }
    // Register the shortcode
    add_shortcode('wptelegram_user_id_form', 'wptelegram_user_id_form');
    
    
    • This reply was modified 11 months, 2 weeks ago by webfantastic.
    Plugin Author Irshad Ahmad

    (@irshadahmad21)

    I’m glad you figured it out. That’s exactly what I suggested above.

    That solution will work for you but not for every user’s use-case. So, adding that shortcode to the plugin serves no purpose.

    Thanks

    Thread Starter webfantastic

    (@webfantastic)

    This will work for any user who uses the website builder WPBAKERY, Elementor and others or a custom personal account. Considering that you have created a shortcode for displaying the authorization button via telegram, your comment seems ridiculous.

Viewing 12 replies - 1 through 12 (of 12 total)
  • The topic ‘form on the account page’ is closed to new replies.