Here are some pointers:
Why are you using output buffering in tb_get_follow_unfollow_links()? I see no reason this is needed.
In tb_get_follow_unfollow_links() only echo 1 button. On page load use php to decide what classes and button text you have to set.
With jQuery change the button when you get a successfull ajax return. Change the button class, so you can trigger a different ajax call on click.
Use .on to get events from dynamic (loaded from ajax) elements: $( "#container" ).on( "click", ".element", function() {});.
Your second question is easy to detect with some debugging.
To check if the user already subscribed, you can do something like this:
$following = get_user_meta( $user_id, '_tb_following', true );
if( ! in_array( $id_to_check, $following )) { // user not subscribed, do it now }
Regards, Bjorn
Related Posts:
- delete_user_meta Delete one value out of array
- AJAX search posts and pages
- Using AJAX to generate front end / viewer end pages
- woocommerce search by sku and title ajax
- How to get CPT category checkbox list and show post of selected(multiply) checkboxes via ajax?
- Update User Meta Via Ajax
- Shipping Refund via Stripe Creates New Order Instead of Updating Original Order
- How can i list random post from multiple category?
- how do i remove posts from a WP_Query so the pagination is right?
- WooCommerce get_price returning wrong price when used via ajax
- Shortcode button dosent work for all posts. Work for first post only
- How to keep users unique id stored in session in addition to IP in WordPress plugin?
- Accessing post’s meta data based on user’s click of a post
- AJAX button run function
- How to get current post user id
- WooCommerce shop page orderby [closed]
- When to use action hooks and plugins
- Simple ajax call not working in wordpress plugin
- Why get_posts() not returning only selected category posts from Custom Post Type?
- Get posts from WP_Query and format them on admin_head
- Not getting author rank when using return
- How to create user groups and allow custom posts and plugin modify/access to specific group?
- How to query the custom fields by language?
- Form isn’t inserting data into database with ajax plugin
- How do I “get the next 10 posts after post_id == x”?
- New User Form – Custom Menu Page
- WordPress Central User Database
- What’s the best way to implement AJAX in WordPress?
- How to Create a Custom Panel and Fields in Post Page [Plugin]
- How to read individual user’s directory and display content to that specific user?
- How to put JQuery/Ajax inside shortcode?
- switched from query_posts to WP_query, not working now?
- WordPress Ajax Posting from App
- __callStatic method handler passed to add_action causes bug in PHP
- Using a custom plugin to capture input data via Ajax and PHP
- wp_set_auth_cookie causes 403 error in the wooCommerce checkout
- DROP TABLE with uninstall hook not working
- Ajax contact form widget plugin data not insert in database
- woocommerce_package_rates not fired when wordpress woocommerce accessed as non ajax
- Theme is Causing Ajax Conflicts for a plugin I cant identify it
- Why WordPress plugin url ajax doesn’t work?
- How to change this WP_Query to get all ProductIDs and not only specific one?
- wordpress, search form using ajax
- jquery not calling php function
- Search for categories
- AJAX in plugin wp_send_json() sending html
- How can I copy all users to newly created site on a multisite network in WordPress?
- Best place for if/else piece of code related to custom plugin?
- Making sure that a plugin’s scripts and stylesheets are included for dynamicaly loaded content
- How to call WordPress function other files
- Insert content of a post into another
- Ajax call returning 0
- How to create restrict content to users (by user, not by role)
- Ajax with plugins returns 0
- WordPress + JavaScipt + AJAX + MySQL: insert query for form
- Ajax fail and get 504 error
- WP_Query and NULL meta keys
- Ajax Search Lite: Customize Autoscroll
- Enable users to change change and add taxonomies of posts
- admin-ajax.php warning max input vars exceeded on layered pop plugins [closed]
- how to use in custom single.php template using php?
- How can I change the meta_key for a particular piece of information?
- WordPress Integration with Google Groups
- Best place to load wp_ajax_the_ajax_hook action in plugin
- jQuery.post not working within shortcode – WordPress Ajax
- Create tabs in admin options page from custom post type loop
- How to load wp_editor via AJAX
- How can I inject options into an select tag inside the widget form?
- Init plugin again after ajax call finish
- Custom User meta field display
- WordPress page and plugin list using sql query
- Display wordpress post’s in popup?
- How to create a custom shortcode based on the layout?
- Using color picker in plugin, does input attribute order matter?
- How to handle cookies from a WordPress plugin on a cached page?
- Ajax : Call undefined function plugin_function() … can’t call any plugin function
- wordpress file upload with ajax when site is ajaxyfi
- Post Comments with Ajax in WordPress
- AJAX search as you type? [duplicate]
- WordPress api call using wp-ajax returns error 400
- AJAX call – failling to call do_action
- how to insert data in wordpress table usnig jquery ajax
- WooCommerce search products between price range using WP_Query
- Using wpdb without loading all plug-ins via wp-load.php
- ACF: post query, hide duplicate values [closed]
- What are the Best Practises When Using AJAX in Plugin Development?
- Redirect to another page using contact form 7? [closed]
- edit_user_profile and show_user_profile are not firing inside a class
- Admin AJAX doesn’t work in plugin admin page – Even though code is copied verbatim from WordPress Codex
- AJAX fileupload – TypeError: not a function ajaxSubmit()
- How to insert multiple postmeta values with one query?
- Call plugin with php function
- How to create multiple users at once?
- Render Modula Plugin Shortcode On Ajax Request
- Shortcode to update user meta
- How to Loop Through all Posts and Count Attachments using Get Media Attachments
- Multisite – maximum number of users with specific role
- AJAX on Front-End Button Click not working – Custom Plugin
- How do I get the user ID of the user that was updated in WordPress?
- How to handle WordPress Plugin Front-end AJAX Call [duplicate]