• Resolved Alex

    (@alexius94)


    Hi,

    Is there a way for me to add custom attributes to the shortcode like I need to know from which page the user register in from my site, so something like [nextend_social_login from_page="homepage"]

    Could you give me some pointers on how to modify the plugin? I’ve managed to pass the atts to the shortcode but I’m not sure how to access retrieve them from the NextendSocialUser::register function

Viewing 4 replies - 1 through 4 (of 4 total)
  • Ramona

    (@nextend_ramona)

    Hi @alexius94

    You can use the trackerdata attribute in your shortcode for this. E.g.: [nextend_social_login trackerdata=”homepage”]

    and you can use a code like this to save it down:

    add_action('nsl_register_new_user', function ($user_id) {
        if (NextendSocialLogin::getTrackerData() == "homepage") {
            $user = new WP_User($user_id);
            add_user_meta($user->ID, 'registered_from', "homepage");
        }
    });

    then you can use the get_user_meta() https://codex.wordpress.org/Function_Reference/get_user_meta
    to display this information anywhere.

    You could make this a bit more dynamic using cookies. E.g. by setting up a cookie that stores the URL of the current page and saving that down at the add_user_meta() function.

    Thread Starter Alex

    (@alexius94)

    Nice that great! Thanks a bunch.

    Thread Starter Alex

    (@alexius94)

    Hi, another question, where would the best place to place the code? In functions.php or somewhere in the plugin folder?

    Plugin Support Gabor

    (@nextendweb_gabor)

    Hi @alexius94!

    You should probably write a new plugin for this. This could help getting started, if you haven’t done that before:
    https://corpocrat.com/2009/12/27/tutorial-how-to-write-a-wordpress-plugin/

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

The topic ‘Add custom attribute to shortcode’ is closed to new replies.