Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Author Ipstenu (Mika Epstein)

    (@ipstenu)

    🏳️‍🌈 Advisor and Activist

    Given than the plugin has some components that can be edited and adjusted per site (by intent) this may not work out well.

    But. You can use do_shortcode() to echo shortcodes in templates: http://codex.wordpress.org/Function_Reference/do_shortcode

    Thread Starter antoniorigo

    (@antoniorigo)

    Thanks Mika for this awesome plugin. Very useful functionality!

    Didn’t know about that function, it will come handy, i’m sure.

    The thing is I’d like to expand your button/shortcode functionality, I want to make a single button that does:

    1) If visitor is not registered on the multisite, button shows “Subscribe” text. on click, show modal so the visitor can sign up with facebook, then automatically sign in and add as suscriber of current site. Button text changes to “Subscribed”.

    2) If the visitor is registered on the multisite, but not registered to the current site, button shows “Subscribe” text. on click, user is added as subscriber of the current site. Button text changes to “Subscribed”.

    I have the first use case working as described.

    Now I’m trying to get the second use case going, and I might need to tweak your code so it would work as i need it to.

    So far i’ve tried using the form the shortcode outputs with no success:

    <form action="?jmm-join-site" method="post" id="notmember">
    	<input name="action" value="jmm-join-site" type="hidden">
    	<input value="Join This Site" name="join-site" id="join-site" class="button" type="submit">
    </form>

    Am I missing something?

    Thanks again,
    A

    Plugin Author Ipstenu (Mika Epstein)

    (@ipstenu)

    🏳️‍🌈 Advisor and Activist

    <form action="?jmm-join-site" only works because the plugin’s running.

    https://plugins.trac.wordpress.org/browser/join-my-multisite/trunk/lib/shortcode.php#L63

    That’s why. You’re not triggering the do_action because the form action doesn’t know what ?jmm-join-site is.

    Thread Starter antoniorigo

    (@antoniorigo)

    The plugin is activated, and works just fine with the shortcode con a blog post.

    it doesn’t work on a custom_post harcoded.

    Plugin Author Ipstenu (Mika Epstein)

    (@ipstenu)

    🏳️‍🌈 Advisor and Activist

    The code isn’t running on the hard coded page. You have to write your own action to call the do_action, or use the do_shortcode to embed it and not the form.

    That’s in theory mind you.

    Thread Starter antoniorigo

    (@antoniorigo)

    Thanks, you’ve been a great help.

    I finally managed to make this work with WordPress Social Login and some custom code based on your plugin:

    if (isset($_POST['subscribe'])) {
        $blog_id = get_current_blog_id();
        $user_ID = get_current_user_id();
        $role = 'subscriber';
        add_user_to_blog($blog_id, $user_ID, $role);
    }
    <form action="?subscribe" method="post">
        <input type="hidden" name="action" value="subscribe">
        <input type="submit" value="Subscribe" name="subscribe" id="subscribe" class="button">
    </form>

    Couldn’t have done it without you!

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

The topic ‘Hardcode [join-this-site] button/functionality’ is closed to new replies.