Support » Developing with WordPress » Need to add action by login

  • Hi there,

    I have an button exemple : xyz()
    That needs to be executed by login,

    I search the code, until now without positive results.

    Maybe Genius under Us can help?

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

    (@bcworkz)

    Thread Starter hellehelle

    (@hellehelle)

    @bcworkz yes in this direction,
    i did try this one but did not work for me.

    Maybe i add it on the wrong place

    Where should this part get add?

    The user logging and in the same time this button
    Xyz() have to be executed

    He and thank you for the reply

    • This reply was modified 1 year, 3 months ago by hellehelle.
    Moderator bcworkz

    (@bcworkz)

    The theme’s functions.php or a plugin’s main file are common places. Anything that executes before the related do_action() call will work. If your site has some sort of alternative sign on process like “single sign on”, there’s a chance the action doesn’t fire. It does fire for sign ons through the default wp-login.php form.

    Thread Starter hellehelle

    (@hellehelle)

    @bcworkz Thank yoy for the reply and follow up

    this is the base button code exemple:

    <?php if ( $data[‘show_button’] ):?>
    <div class=”Test-wrapp”>
    <button class=”Test2-bttn” onclick=”Test3();”><?php _e(‘Test4’, ‘Test5’);?></button>
    </div>
    <?php else :?>
    <?php if ( $data[‘warning_message’] ):?>
    <p><?php echo $data[‘warning_message’];?></p>
    <?php endif;?>
    <?php endif;?>

    also this is this code that needs to get executed when the user login the first time,
    as you can see it is an onclick button

    Moderator bcworkz

    (@bcworkz)

    Ah, callbacks to “wp_login” aren’t expected to generate output. It may or may not do any harm, but don’t expect any such output to be visible. Additionally, Test3() is client side script, “wp_login” executes server side. There’s no mechanism for it to directly call client side script.

    If you want, you could use the “redirect_to” filter to manage what page is seen after login. On that page you could have such a button and execute Test3() on click.

    Thread Starter hellehelle

    (@hellehelle)

    @bcworkz Thank you for the follow up

    This is exactly what I have today.
    One click,
    but what have to be is when user login automatically this button get push in the same time.

    Do you know something about WordPress slow picture upload?
    I have two hundred mbs connection, eight gb ram, and need one minute to upload simple picture i do with my phone.

    Moderator bcworkz

    (@bcworkz)

    It’s difficult to say where the bottleneck is, but I’d place good odds on your hosting server. It’s probably optimized for serving data, not writing file data (as it should be). Granted, that’s still unusually slow. Part of the problem may be your phone. Some take quite sizable images, far bigger than we’d need for web pages. Uploading reasonably sized images would help reduce time, though the speed remains the same.

    If it remains a significant hindrance, try complaining to your host. Maybe they’ll move you to a less loaded server. Or they’ll try to sell you a more powerful plan. If the upload speed is bad enough, consider moving hosts.

    Thread Starter hellehelle

    (@hellehelle)

    @bcworkz Thank you for the follow up

    Phone is fine
    Server ubuntu 18.04.4
    Connection 190 mbs upload and download

    Writing data, how can i configure this?

    Moderator bcworkz

    (@bcworkz)

    I’m not sure you can, it’s the nature of servers. Usually the reason for unexpectedly slow performance is the server is overloaded, sharing too many different sites.

    Thread Starter hellehelle

    (@hellehelle)

    @bcworkz Thank you for the follow up

    It is vps with four site

    To come back to the button that needs to get push before to use the site.

    Is it possible to open an pop up that first close when the button get pressed and only visible for logged in user that did not push this button.

    Moderator bcworkz

    (@bcworkz)

    Four sites on your VPS? That doesn’t mean there are not other VPSs on the same physical server taking up its time.

    I don’t recommend a popup because they’re difficult to open automatically due to past abuse. It normally takes user interaction to open one. What you’re probably actually thinking of is a modal. It’s very similar in function, but it opens in the same window, obscuring the page with a dialog box.

    If the user must be logged in to even see the page, you can save an indication that they already used the button in their user meta. Page templates can include the necessary HTML and CSS to display a modal. But it’s only actually displayed if the user is logged in and there is no user meta value indicating they’ve already done this.

    Thread Starter hellehelle

    (@hellehelle)

    @bcworkz Thank you for the follow up

    For the server i looking to upgrade to more powerful with 1g connections and some more ram,from vps to dedicated.

    I did not get it for the button.

    Obscuring with dialog box, yes this is right.
    Open in iframe the page, on that page the button.

    Once the button get push (onclick)
    The site open.

    This dialog box open until the button get push.
    Once is push it does not open again.

    Not possible to enter the site without to push this button.

    In this form :
    Go to the site, registry, login, push the button, use the site.

    Do you know how to code it?

    Moderator bcworkz

    (@bcworkz)

    Yes, a button in an iframe is feasible. They can be sort of a pain due to CSP restrictions in modern browsers. There’s really no need, the HTML aspect is very simple — two buttons, some text, all within a div element. It could simply be added to page content or template code.

    How are you preventing access to site content? Or would that be part of this exercise? If part of this, template code is the way to go IMO.

    I do know how it would be coded, but TBH, I’m not going to code it for you. There are plenty of modal examples available on the ‘net that could be adapted. I’m willing to help with any problems you encounter in your own efforts, but I’m not going to just do the entire thing for you.

    Thread Starter hellehelle

    (@hellehelle)

    @bcworkz Thank you for the follow up

    Still just finished to move to another server more powerful,
    But still get the same issue with the uploading from files like photo and video.

    Very slow even with 1gbit connection

    Do you know something about this issue?

    Moderator bcworkz

    (@bcworkz)

    Sorry to hear there are still slow uploads. It’s inescapable that writing data is much slower than reading data. If it’s not the server, then somewhere in the communication lines there is a bottleneck. If you’re using your phone’s mobile data, that speed can be pretty erratic. Even for a physical Internet connection, some ISPs will give you great download speeds, but their upload speeds are relatively slow. Sometimes a factor of 10 slower.

Viewing 15 replies - 1 through 15 (of 28 total)
  • The topic ‘Need to add action by login’ is closed to new replies.