BuddyDev

Search

Post As Group Name – Not As User Profile

Tagged: 

  • Participant
    Level: Initiated
    Posts: 11
    Roni Gabriel on #34445

    People are use to pages on Facebook. When they post a new post on Facebook as an admin of that page it does not show their personal profile as posting to the page.

    How can you setup groups to have the option that when admin or moderator posts to the group it shows just groups name?

    Example group name: Outdoor Hiking

    When you post it should say, “Outdoor Hiking created a new post”, and not “John Doe creating a new post in the group Outdoor Hiking”.

    Can this be done with a snippet code?

    Thank you for helping.

  • Keymaster
    (BuddyDev Team)
    Posts: 24149
    Brajesh Singh on #34446

    Hi Roni,
    Thank you for the question.

    You can do it by filtering the group activity actions to replace user with the the group.

    Regards
    Brajesh

  • Participant
    Level: Initiated
    Posts: 11
    Roni Gabriel on #34448

    Thank you. Is this setting in the wordpress admin panel somewhere?

  • Keymaster
    (BuddyDev Team)
    Posts: 24149
    Brajesh Singh on #34457

    Hi Roni,
    No, you will need to custom code it.

    I will ask @ravisharma tomorrow to see if he can put some code as example here.

    Regards
    Brajesh

  • Participant
    Level: Initiated
    Posts: 11
    Roni Gabriel on #34460

    That will be great! I appreciate it and so will our users!

  • Keymaster
    (BuddyDev Team)
    Posts: 24149
    Brajesh Singh on #34476

    Hi Roni,
    Hope you are doing well.

    Just an update on this, we had a holiday today due to Diwali here(festival). I did not consider that while replying earlier.


    @ravisharma
    will be available on Monday and assist you then.

    Thank you
    Brajesh

  • Keymaster
    Level: Yogi
    (BuddyDev Team)
    Posts: 2908
    Ravi on #34495

    Hello Roni,

    Please check the following code. It will modify activity action for activities posted by the group’s admin or moderator.

    
    /**
     * Modify group action
     *
     * @param string               $action   Group action.
     * @param BP_Activity_Activity $activity Activity object.
     *
     * @return string
     */
    function buddydev_modify_groups_activity_action( $action, $activity ) {
    
    	if ( 'groups' != $activity->component || 'activity_update' != $activity->type ) {
    		return $action;
    	}
    
    	if ( groups_is_user_admin( $activity->user_id, $activity->item_id ) || groups_is_user_mod( $activity->user_id, $activity->item_id ) ) {
    		$group = groups_get_group( $activity->item_id );
    
    		$action = sprintf( '<a href="%s">%s</a> posted an update.</a>', bp_get_group_permalink( $group ), $group->name );
    	}
    
    	return $action;
    }
    add_action( 'bp_get_activity_action', 'buddydev_modify_groups_activity_action', 10, 2 );
    
    

    Please let me know if it works or not.

    Regards
    Ravi

  • Participant
    Level: Initiated
    Posts: 11
    Roni Gabriel on #34500

    Thank you very much. However, where do I place this code? What file?

  • Keymaster
    Level: Yogi
    (BuddyDev Team)
    Posts: 2908
    Ravi on #34503

    Hello Roni,

    Try in “bp-custom.php file”. Take a look at the following URL:

    https://buddydev.com/docs/buddypress-guides/what-is-bp-custom-php/

    Regards
    Ravi

  • Participant
    Level: Initiated
    Posts: 11
    Roni Gabriel on #34506

    YES! It worked! Thank you Ravi! This is such a huge needed feature for Buddypress! Corporations that sign up for a social network don’t want their personal user profile to be seen when they post on their company group page.

    Thank you very much!

You must be logged in to reply to this topic.

This topic is: not resolved