@prefix sioc: <http://rdfs.org/sioc/ns#> .
@prefix dc: <http://purl.org/dc/elements/1.1/> .
@prefix dcterms: <http://purl.org/dc/terms/> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
@prefix content: <http://purl.org/rss/1.0/modules/content/> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .

<https://lhero.org/portfolio/lh-buddypress-post-likes/>
  a sioc:Post ;
  dc:title "How liking works" ;
  dcterms:identifier 153985 ;
  dc:modified "2026-11-07T02:05:50Z"^^xsd:dateTime ;
  dc:created "2026-11-07T02:05:50Z"^^xsd:dateTime ;
  sioc:link <https://lhero.org/portfolio/lh-buddypress-post-likes/how-liking-works/> ;
  sioc:has_creator <https://lhero.org/author/1/#account> ;
  sioc:has_container <https://lhero.org/#posts> ;
  content:encoded "<ul class=\"lh_portfolio-meta\"><li><strong>Part of:</strong> <a href=\"https://lhero.org/portfolio/lh-buddypress-post-likes/\">LH Buddypress Post Likes</a></li></ul><h2 class=\"wp-block-heading\">Liking</h2><p class=\"wp-block-paragraph\">A like is a comment of type <code>like</code> on the post, by the member who liked it. Adding one also adds a BuddyPress activity item; removing one deletes both. Like comments are left out of the post&#8217;s comment count and never trigger comment notification emails. A post can be liked when it is publicly viewable, in any public status such as published or archived.</p><p class=\"wp-block-paragraph\">Logged-in members get a Like or Unlike button, a small form that posts back to the same page and then redirects, so reloading never likes twice. Nothing is ever liked by following a link.</p><h2 class=\"wp-block-heading\">Liking before logging in</h2><p class=\"wp-block-paragraph\">Logged-out visitors get a Like link to the login page that returns them to the post. The link is the same for every visitor, so cached pages stay correct.</p><ol class=\"wp-block-list\"><li>Tapping it saves the pending like in the browser (IndexedDB database <code>lh-pending-actions</code>, store <code>intents</code>, key <code>current</code>: one pending action at a time, newest wins), then goes to the login page. It expires after 15 minutes.</li><li>After logging in, on that post only, the like is sent to the REST API, the pending like is cleared and the button shows Liked with a brief Undo.</li><li>Without JavaScript, or on another device, the return URL&#8217;s <code>lh_bp_pls-intent=like</code> shows a highlighted Confirm your like button instead. The parameter only changes the button; the member still has to press it.</li></ol><h2 class=\"wp-block-heading\">REST API</h2><p class=\"wp-block-paragraph\">Both routes take a <code>post_id</code>, need a logged-in user (with the <code>wp_rest</code> nonce for cookie authentication) and return <code>post_id</code>, <code>liked</code> and the post&#8217;s like <code>count</code>.</p><ul class=\"wp-block-list\"><li><code>POST /wp-json/lh-bp-pls/v1/like/</code>: 409 if already liked, 404 if the post can&#8217;t be liked.</li><li><code>POST /wp-json/lh-bp-pls/v1/unlike/</code>: 409 if not liked.</li></ul><h2 class=\"wp-block-heading\">Hooks</h2><ul class=\"wp-block-list\"><li><code>lh_bp_pls_init_plugin</code>: return false to stop the plugin loading.</li><li><code>lh_bp_pls_intent_ttl</code>: seconds a pending like stays valid (default 900).</li><li><code>lh_bp_pls_return_block_name</code>: name of the Like button block.</li><li><code>lh_bp_pls_like_action</code>: text of the BuddyPress activity item.</li></ul><h2 class=\"wp-block-heading\">Requirements</h2><p class=\"wp-block-paragraph\">BuddyPress and WordPress 6.7 or later. The front end uses the idb-keyval library: the shared copy from LH idb-keyval when that is active, otherwise the plugin&#8217;s own bundled copy.</p>"^^rdf:XMLLiteral ;
  sioc:content "Part of: LH Buddypress Post LikesLikingA like is a comment of type like on the post, by the member who liked it. Adding one also adds a BuddyPress activity item; removing one deletes both. Like comments are left out of the post&#8217;s comment count and never trigger comment notification emails. A post can be liked when it is publicly viewable, in any public status such as published or archived.Logged-in members get a Like or Unlike button, a small form that posts back to the same page and then redirects, so reloading never likes twice. Nothing is ever liked by following a link.Liking before logging inLogged-out visitors get a Like link to the login page that returns them to the post. The link is the same for every visitor, so cached pages stay correct.Tapping it saves the pending like in the browser (IndexedDB database lh-pending-actions, store intents, key current: one pending action at a time, newest wins), then goes to the login page. It expires after 15 minutes.After logging in, on that post only, the like is sent to the REST API, the pending like is cleared and the button shows Liked with a brief Undo.Without JavaScript, or on another device, the return URL&#8217;s lh_bp_pls-intent=like shows a highlighted Confirm your like button instead. The parameter only changes the button; the member still has to press it.REST APIBoth routes take a post_id, need a logged-in user (with the wp_rest nonce for cookie authentication) and return post_id, liked and the post&#8217;s like count.POST /wp-json/lh-bp-pls/v1/like/: 409 if already liked, 404 if the post can&#8217;t be liked.POST /wp-json/lh-bp-pls/v1/unlike/: 409 if not liked.Hookslh_bp_pls_init_plugin: return false to stop the plugin loading.lh_bp_pls_intent_ttl: seconds a pending like stays valid (default 900).lh_bp_pls_return_block_name: name of the Like button block.lh_bp_pls_like_action: text of the BuddyPress activity item.RequirementsBuddyPress and WordPress 6.7 or later. The front end uses the idb-keyval library: the shared copy from LH idb-keyval when that is active, otherwise the plugin&#8217;s own bundled copy." ;
  sioc:topic <https://lhero.org/?taxonomy=author&term=cap-1> .

<https://lhero.org/author/1/#account> rdfs:seeAlso <https://lhero.org/author/1/?feed=lhrdf&format=turtle> .
<https://lhero.org/?taxonomy=author&term=cap-1> rdfs:seeAlso <https://lhero.org/?taxonomy=author&term=cap-1&feed=lhrdf&format=turtle> .
